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) Making Decisions with Conditional Statements Super Conditional Challenge

Not sure what I am doing wrong here:

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 < 10 || 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.");

}

script.js
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 < 10 || 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.");

}
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>

2 Answers

Chase Marchione
Chase Marchione
155,055 Points

Hi cøffee _,

You'll want to edit this line:

} else if ( money < 10 || today !== 'Friday' ) {

to

} else if ( money < 10 && today === 'Friday' ) {

So that both the money and today variables are evaluated in that else if clause, and the compiler is checking if today is Friday rather than not. (Side note: you could technically get away with not checking for money in that statement, but it seems like the challenge, based on the instructions, would prefer you checked for it.)

Hope this helps!

It's easier to not check the money at all in the last else if condition. If you've reached that far then you know you don't have enough money and you only need to make sure that it's still Friday.

If you do include it then you run the unnecessary risk of having gaps in the money coverage. For instance, it's Friday and you have exactly 10 dollars. It's going to fall through to the else block.

If you're going to include it then it should be

money <= 10

Ah, thanks for the quick response CJ Marchione!