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 trialhasinaakhter
8,540 PointsMath challenge is not Working!
Hello
In the math challenge section, I wrote the code correctly as below:
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal=9.99*47;
var profit=9.99*47-5.45*47;
var profitPerUnit=9.99*47-5.45*47/47;
But I am not passing the test as the computer showing the code I wrote is not correct.
Please help.
3 Answers
Tanja Schmidt
11,798 PointsHi, I can't find the challenge you are referring to right now, but my guess is that you need to switch the absolute values with the variables in your calculations. The whole point of your first variables is to make life easier if a value changes for some reason, e.g. the retailPrice drops from 9.99 to 6.99: If you use the variable retailPrice and not the absolute number, you only need to change the value once and the rest will follow automatically.
For example:
var salesTotal = retailPrice * quantity;
... and so on!
Bruno Areias
5,181 Points(LOL, posted the answer as a comment :/ )
Hi, never done the challenge you're on. I would guess they are asking you to calculate the sales, profit and profitperUnit based on the above variables.
So I would guess the correct answer to be something like:
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal=retailPrice*quantity;
var profit=salesTotal-wholesalePrice*quantity;
var profitPerUnit=profit/quantity;
In that way if you change any of the variables wholesalePrice, retailPrice or quantity the script will still work correctly.
hasinaakhter
8,540 PointsThanks to you both. Its working on. Have a great day.
Bruno Areias
5,181 PointsBruno Areias
5,181 PointsHi, never done the challenge you're on. I would guess they are asking you to calculate the sales, profit and profitperUnit based on the above variables.
So I would guess the correct answer to be something like:
In that way if you change any of the variables wholesalePrice, retailPrice or quantity the script will still work correctly.