Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.