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

kingdavid igbayilola
kingdavid igbayilola
8,678 Points

how can i fix the or operator?

my answer is write but still showing me the error message and don't just know what is wrong

script.js
var money = 9;
var today = 'Friday'

if ( money >= 100 || today === 'monday' ) {
  alert("Time to go to the theater");    
} else if ( money >= 50 || today === 'tuesday' ) {
  alert("Time for a movie and dinner");    
} else if ( money > 10 || today === 'wednesday' ) {
  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.");
}
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>

3 Answers

Your operators are wrong now you say as money OR today is correct run this. But the test you want to do is if money AND today is correct, do this run this. (OR = ||) (AND = &&) The last if else is to complex need one check.

Niki Molnar
Niki Molnar
25,698 Points

Hello

It sometimes helps if you read through the if/else statements out loud - but I would revert to the original before you changed the days:

if ( money >= 100 || today === 'Friday' ) {
  alert("Time to go to the theater");    
}

So, this first one says "If I have 100 or more in money OR today is Friday, then tell me that it's time to go to the theater"

As today is Friday, the if/else will always stop on this first alert, as you either have more than 100 in money OR today is Friday, so the latter is true.

Once you read them through, you'll see what you need to do, which is to change the operators to && and remove the ! from the if ( today !== 'Friday' ) option.

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

Good luck!

Adam Beer
Adam Beer
11,314 Points

You are so close. If you restart the challenge then use Logical OR (||) operators everywhere, and change last not equal value or not equal type to equal value and equal type. Hope this help.