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 trialChristopher Flores
6,898 PointsCan't get it. Must be over-thinking it... Any JavaScript experts in the house?!
I'm not quite getting it.
And at this point I'm just messing around trying to throw anything to get the answer right.
|| && === anything
originally for the last 'else if' there was no || which I believe is correct but probably not. I also put a && just to see it it'd work but no cigar. For the 'money' part of the last 'else if' I also tried > and >=... maybe it's <=, because < means there's not enough money........ idk
I also put a ; for the var today = 'Friday'(;) line/statment/string part but that probably didn't matter one way or another.
What am I not getting right?
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
Jason Anders
Treehouse Moderator 145,860 PointsYou are on the right track. There are just two things that need fixing up.
- One, you were right to use
&&
, but you have to remember about the other conditionals in the code block. right now, it will never go beyond the firstif conditional
because it is using||
(OR). With an OR check, only one of the conditions needs to return true, and becausetoday
is Friday, theif check
will returntrue
regardless of themoney
. So, all the conditionals (including that finalelse/if
) should be using&&
(AND) because both conditionals need to return true for the check to pass accurately.
- In the final
else/if
, once the||
is changed to&&
, your checks are correct, except you are checking for the wrong amount ofmoney
. You are testing for less than $9.00, but you need $10.00 to go out. So, if you were to have $9.75, you wouldn't have enough to go out, but it will still pass your conditional because it is not less than 9. You just need to test for any amount that is less than 10 instead.
Otherwise, it looks good.
Nice Work!! :)
Christopher Flores
6,898 PointsChristopher Flores
6,898 PointsThanks Jason! With your help I was able to pass the challenge.