Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialkerry bennett
1,976 Pointsthis question doesn't make sense. its says store the price per unit and then divide the price per unit by quantity.
The total profit for this question would be retail - wholesale * quantity then it says divide by quantity. the price per unit what its asking is retail - wholesale ? will give price per unit. No division necessary. Am i reading this wrong?
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - (wholesalePrice * quantity);
var pricePerUnit = retailPrice - wholesalePrice;
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Chyno Deluxe
16,936 PointsThere are a couple things that need to be changed in your final variable. First, is your variable is incorrect from what the challenge is asking of you.
Secondly, it is asking that you divide the profit by quantity. Like Below.
var profitPerUnit = profit / quantity;
I hope this helps.
Steven Parker
231,269 PointsYour math is good, and probably an even better solution, but in this challenge they just want to see you use the divide (/) operator. If they were only looking for the result, your approach would be good.
But you'd still need to put it in a variable named profitPerUnit, not "pricePerUnit".
kerry bennett
1,976 PointsThanks!