JavaScript JavaScript Numbers Working with Numbers Doing Math

james presley
james presley
4,569 Points

can anyone show me what is wrong with my code please and thankyou.

script.js
const wholesalePrice = 5.45;
var retailPrice = 9.99;

const quantity = 47;

const salesTotal = retailPrice * quantity
const profit = salesTotal - (wholesalePrice * quantity);

const profitPerunit = salesTotal / quantity;

1 Answer

Hi James,

last task is to get profit per unit. You've already calculated total profit and now you only need to divide total profit by quantity to get profit for one unit. Also make sure to name your variables correctly as code challenge might check on naming your variables too.

const wholesalePrice = 5.45;
const retailPrice = 9.99;
const quantity = 47;

const salesTotal = retailPrice * quantity;
const profit = salesTotal - wholesalePrice * quantity;
const profitPerUnit = profit / quantity;