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 someone can help me to resolve this problem I am trying to solve. Can you please find the mistake in the code.

else if (money >= 1 && today === 'Friday')

but alert message is printing wrong.

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 >= 1 && 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>

3 Answers

Chidiebere Ekennia
Chidiebere Ekennia
5,950 Points

I've gone over this before Nasim. It seems you edited the original code quite a bit. But that's Ok. The bug that's left for you to correct would be in the 3rd "else if" code block. The logic/condition is wrong there. The proper condition should read (money < 10 && today === "Friday"). That way, the statement "It's Friday, but I don't have enough money to go out" would be valid, since var money = 9

Thank you for reply, I tried your code but problem is not solved, When I run the code message is same as before.

Chidiebere Ekennia solved my problem. Thanks a lot.