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 Making Decisions in Your Code with Conditional Statements Use Multiple Conditions

Can some body help me please to solve the problem. I have checked the code so many ways but the out come is not correct.

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

if ( money > 10 || 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("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 charset="utf-8">
    <title>JavaScript Basics</title>
  </head>
  <body>
    <script src="script.js"></script>
  </body>
</html>

5 Answers

Mauricio Ariza
Mauricio Ariza
1,731 Points

Nasim, I could solve it :) I could solve it by adding && to the first and second ( changing them from their original value which was ||) and changing the third value to === . const money = 9; const today = 'Friday'

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

Hey Nasim, it looks like you are using the 'or' ( || ) operator when you might want to use the 'and' (&&) operator. If you want to make sure that BOTH conditions evaluate to true, you will want to use the 'and' operator.

I used && operator but in this case the prompt is the same like below ; It looks like there is at least one logical OR operator (that's the || symbols). Those test if just one of the conditions is true.

when I use pipe character || then it thoroughgoing the message like below :

Bummer: SyntaxError: script.js: Unexpected token 1 (8:21)

Can you look again please though the code and answer me again. I am stuck just this problem other wise the whole track of FRONT END WEB DEVELOPMENT is already completed. I will highly appreciate your help.

Mauricio Ariza
Mauricio Ariza
1,731 Points

I have your same problem Nasim. If someone can help us that would be great.

I thank you from my bottom of the hard you really solved my problem. Thanks again a lot.