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 trial

JavaScript JavaScript Basics (Retired) Working With Numbers Doing Math

Ryan Morales
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ryan Morales
Full Stack JavaScript Techdegree Graduate 33,933 Points

Task 1 passes then Task 2 says it is not passing for the wholeSalePrice variable problem

What could be the problem here?

script.js
var wholeSalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal = retailPrice * quantity;
var profit = salesTotal - (wholeSalePrice * quantity);
index.html
<!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
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey 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 :)

lol beat me to it sir

Get 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
Jason Anders
Treehouse Moderator 145,860 Points

Hi 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.

Yeh but he had the variable name uppercase also in his code

var 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
Jason Anders
Treehouse Moderator 145,860 Points

Hey 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.

Lol yeah

Hey 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);