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 trialRyan Morales
Full Stack JavaScript Techdegree Graduate 33,933 PointsTask 1 passes then Task 2 says it is not passing for the wholeSalePrice variable problem
What could be the problem here?
var wholeSalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - (wholeSalePrice * quantity);
<!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
Jason Anders
Treehouse Moderator 145,860 PointsHey Ryan,
You have a capital S in WholesalePrice on the last line. If you change that to lowercase it will pass.
var profit = salesTotal - (wholesalePrice * quantity);
Jason :)
Colton Ehrman
Courses Plus Student 5,859 PointsGet rid of your parenthesis in
var profit = salesTotal - (wholeSalePrice * quantity);
also, I'm not sure if this matters, but in the challenge the variable is wholesalePrice not wholeSalePrice
Jason Anders
Treehouse Moderator 145,860 PointsHi Colton, the parenthesis are a good thing to have. Yes, it will work without them, but it's easier to read and understand (if you were looking at the code and not have written it) with them there. This way you know that (wholesalePrice * quantity) is meant to be one value. There really is only 2 values... without the parenthesis, however, it could be interpreted as being 3 'separate' values.
The problem was only with the uppercase S in wholesalePrice. Variable names are case-sensitive.
Colton Ehrman
Courses Plus Student 5,859 PointsYeh but he had the variable name uppercase also in his code
Colton Ehrman
Courses Plus Student 5,859 Pointsvar wholeSalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - (wholeSalePrice * quantity);
See, both are uppercase, so technically it should work, just the challenge prolly isnt accepting because it's not the same name as it wants
Jason Anders
Treehouse Moderator 145,860 PointsHey Colton, You are right, and it would work under normal circumstances, but when you're doing a challenge on Treehouse, the error checker is VERY specific, and it asked for 'wholesalePrice' and that's why it wasn't letting him pass. I actually didn't see the first var spelling (good catch), so both would need to be changed in order to pass.
I've been stuck on a challenge for a bit because I didn't put a period at the end of a word. It shouldn't have been there, but the challenge had it... so it was needed... VERY specific. Lol.
Colton Ehrman
Courses Plus Student 5,859 PointsLol yeah
miikis
44,957 PointsHey Ryan,
It looks like you misspelled the wholesalePrice
variable. Below is the correct spelling. Everything else is all good tho.
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - (wholesalePrice * quantity);
miikis
44,957 Pointsmiikis
44,957 Pointslol beat me to it sir