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

Why does it say Task 1 is no longer passing?

Task 1 is completed but when I put in code as it is described in the instructions is comes up with an error.

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>

1 Answer

Ryan Ruscett
Ryan Ruscett
23,309 Points

Hey,

The test work like this.

  1. Do ABC - The code is tested when you hit submit. If it passes you go to the next question.
  2. Do DEF - NOW PAY ATTENTION! Number 2 runs the first test, than the second test.

The reason why the first one is failing, is because the program can't compile. If the program can't compile to begin with, than when task 2 runs the test for task 1 is fails before getting to task 2.

This is because you didn't do part 2 of the challenge right.

  1. Remember order of operations from Math class. Multiplication and Division occurs first, the way to do that is to surround that part in (). Not the whole thing.
var wholesalePrice = 5.45;
var retailPrice = 9.99;
var quantity = 47;
var salesTotal= retailPrice * quantity;
var profit = salesTotal - (wholesalePrice * quantity);

This says profit equals salesTotal minus (whosalePrice times quantity). wholesalePrice and quantity are multiplied first indicated by the () and then that is subtracted from salesTotal.

Does that makes sense? If not, let me know.

Thanks this really helps!