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 trialH Wishnia
12,253 Pointswhy does the last task keep giving me a bummer did you use / ?
it just keeps giving me a bummer did you use the / symbol. everything passes until this challenge.
H Wishnia
12,253 PointsCreate one last variable name profitPerUnit. In that variable store the amount of profit you made for each unit. You can calculate this by dividing the profit by the quantity.
Bummer! Did you use the / symbol to divide profit by quantity?
Preview Recheck work
this is my code it keeps not passing. below is the whole thing
var profitPerUnit = 213.38 / 47;
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
*******this is where my 3 code challenges begin. The first two pass and keeps saying bummer to my third.
var salesTotal = 9.99 * 47;
var profit = 469.53 - 256.15;
var profitPerUnit = 213.38 / 47; // <-------
​
Gloria Dwomoh
13,116 PointsI fixed your code a bit using markdown, if you will like to know how I did it you can check out the video on the right. For this challenge it is good to use the given variables to do the operations instead of the number assigned to the variable.
Dave McFarland
Treehouse TeacherAs gloria, Alex Heil and Emmanuel Obi point out, you should use the variables in your calculations not the actual numbers themselves. That's what's so useful about variables -- they can hold different values.
For example, if the wholesale price of a product changed, you'd just need to change the number placed into the variable like this:
var wholesalePrice = 8.55;
And your program would then be updated with that new value wherever the variable is used.
3 Answers
Gloria Dwomoh
13,116 PointsHi there, it wants you to use the variables given instead of using their numbers.
That is why there is an emphasis in the variable names it mentions, the same applies for the other tasks as well. You aren't giving it what it expects so it doesn't recognize what you did. It expects what it asks which is this... "calculate this by dividing the profit by the quantity"
var profitPerUnit = profit / quantity;
H Wishnia
12,253 Pointsthanks Gloria it worked.
Gloria Dwomoh
13,116 PointsYou are welcome :)
Gerrad Brown
1,497 PointsGloria your answer worked for me, as you said the program did not ask for the + at the end of the / only the /. Thank you very much.
Alex Heil
53,547 Pointshi H Wishnia , actually you're using the correct operator ** / ** in the last task. I guess the code challenge actually wants you to use the existing variables instead of the actual values. at least I just re-did the challenge by using the variables and in this case all answers pass just fine.
this would be the same code you posted here with variables instead:
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - wholesalePrice * quantity;
var profitPerUnit = profit / quantity;
hope that helps and have a nice day ;)
H Wishnia
12,253 Pointsthank you so much. have a great day yourself.
Emmanuel Obi
14,912 PointsStrange. You may try using the variable names to arrive at a value for "profitPerUnit". That is:
var profit = salesTotal - wholeSalePrice * quantity;
var profitPerUnit = profit / quantity;
H Wishnia
12,253 Pointsthat's what worked for me. thanks
Gloria Dwomoh
13,116 PointsGloria Dwomoh
13,116 PointsCan you show us the code you used?