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

Where is my error? I can't figure out what I am doing wrong.

var wholesalePrice = 5.45; var retailPrice = 9.99; var quantity = 47; var salesTotal= retailPrice* 47; var profit = salesTotal-wholesalePrice * quanity;

script.js
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal= retailPrice* 47;
var profit = salesTotal-wholesalePrice * quanity;
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>
Mark Casavantes
Mark Casavantes
Courses Plus Student 13,401 Points

Chris

Are you getting a math error? I am not sure what kind of error you are getting. I think the last line in your script.js file should be:

var profit = (salesTotal-wholesalePrice) * quantity;

I hope this is helpful.

2 Answers

Darren Joy
Darren Joy
19,573 Points

While

var quantity = 47; is good

var salesTotal = retailPrice * 47; is not

it's asking you to multiply retailPrice times quantity. While this is indeed retailPrice * 47, it's attempting to get you to multiply the two variables together to practice that idea of multiplying quantities but through variables..

so

var salesTotal = retailPrice * quantity;

is the correct line

There is also a spelling error on the quantity variable in the last line. It says quanity instead of quantity.

I am guessing it should be salesTotal = retailPrice * quantity.