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 trialPeckeday Slossar
1,069 PointsGetting the proper message to pop up but cant advance. Not sure which variable is wrong.
Anybody see where im messing up lol? Appreciate the help and thank you in advance!
var money = 9;
var today = 'Friday'
if ( money >= 100 || today < 'Friday' ) {
alert("Time to go to the theater");
} else if ( money >= 50 || today < 'Friday' ) {
alert("Time for a movie and dinner");
} else if ( money >= 10 || today < 'Friday' ) {
alert("Time for a movie");
} else if ( today === 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out");
} else {
alert("This isn't Friday. I need to stay home.");
}
<!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>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! Yes, you're getting the correct popup but not for the correct reasons. You have changed all the === 'Friday
to < Friday
, which means that the first 3 will fail. But it's wanting you to change the condition so that it will pass if both the money is there AND the day is Friday. The beginning code starts with it being if the money is available OR the day is Friday. In the altered code, both must be true for the condition to evaluate to true. In the beginning code, only one needs to be true for it to pass.
Change the < 'Friday'
back to ===
and modify the conditions to use the AND operator. Hint: &&
Hope this helps, but let me know if you're still stuck!
Steve Hunter
57,712 PointsHi there,
You can't compare Friday
using a less than sign.
The value of today
is set as Friday
; that's a given. You want to correct the relationship between the testing of money
and today
such that it makes logical sense.
Consider whether these tests should be OR as it may be better testing with AND, &&
.
But you'll need to set today === "Friday"
back on all the lines first.
I hope that helps,
Steve.
Peckeday Slossar
1,069 PointsOk got it!
Steve Hunter
57,712 PointsGood work!
Peckeday Slossar
1,069 PointsPeckeday Slossar
1,069 PointsThank you very much I will go give it a try!