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

I am not understanding how to do this challenge, please help

I do not know what i am supposed to do here, can someone please help me?

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

Something's wrong with this script. The value in the variable money is only 9. But if you preview this script you'll see the "Time to go to the theater" message. Fix this script so that it correctly tests the money and today variables and prints out the proper alert message: "It's Friday, but I don't have enough money to go out"

Sam Baines
Sam Baines
4,315 Points

Sorry I wasnt around to help you with this Carl, but looks like you have it sorted now anyway. Keep going.

3 Answers

Kevin Fitzhenry
Kevin Fitzhenry
30,096 Points

Carl Baker

Something's wrong with this script. The value in the variable money is only 9. But if you preview this script you'll see the "Time to go to the theater" message. Fix this script so that it correctly tests the money and today variables and prints out the proper alert message: "It's Friday, but I don't have enough money to go out"

The double pipe || in JS is the OR operator, meaning if either of the two conditions are true, the statement will be true. && is the AND operator, meaning both conditionals have to be true in order for the statement to be true.

So, the code says: if ( money >= 100 OR today === 'Friday' ) , then alert("Time to go to the theater")

Since today === 'Friday' the condition passes.

We want to test BOTH conditionals and have them both pass in order for the statement to be true. So you want to replace all of the OR operators || with AND operators &&.

Lastly, change this line:

else if ( today === 'Friday' ) { alert("It's Friday, but I don't have enough money to go out");

Delete the exclamation point !, because that is saying if today does NOT equal friday, in order for this condition to be true, today must equal friday, use ===.

Hope that helps.

You need to check the conditions of the if / else if statements. They will be all true as long day = Friday. I won't say the complete solution but I say this: check out the difference of && and ||. Together with the output I think you should get it!

Im not understanding what you are saying

Im having a hard time with JavaScript

I got it finally thanks though