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 trialKim Dallas
11,461 PointsI got the message but it's saying something is wrong
I got the correct message in preview. but it's still saying something is wrong.
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 ( money < 9 || 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>
1 Answer
David McNeill
44,438 PointsHi Kim,
It looks like you have to remove all of the OR operators and replace them with AND (&&
) operators. You've done that for the first 3 conditional checks okay, but the last one still has an OR (||
) operator. If you replace it with &&
it should pass, but you can also just remove the first check (money < 9
) and leave it as today === 'Friday'
and it will still pass.
Hope this helps!
Mariana Belko Nicholas
12,964 PointsDid it work when you changed it to money < 9 && today === 'Friday'?
Mariana Belko Nicholas
12,964 PointsMariana Belko Nicholas
12,964 PointsI'm a bit confused because I tried to change the last "else if" statement to: money < 9 && today === 'Friday' and it didn't pass. It's passing if I change it to: today === 'Friday' It's also passing if I change it to: money === 9 && today === 'Friday', which shouldn't.