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 trialCorinne Jacobs
3,815 PointsWhy 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.
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>
1 Answer
Ryan Ruscett
23,309 PointsHey,
The test work like this.
- Do ABC - The code is tested when you hit submit. If it passes you go to the next question.
- 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.
- 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.
Corinne Jacobs
3,815 PointsCorinne Jacobs
3,815 PointsThanks this really helps!