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 able to get the correct alert still it is showing as wrong..

Question: 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" Error message: Looks like there is at least one logical OR operator -- that's the || symbols. Those test if just one of the conditions are true.

I am not understanding what the error message actually saying

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

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

2 Answers

Hi Rajasekhar,

I agree that it might not be clear from the question, but they want you to check that you have enough money and that it is Friday.

In your current solution you get the right alert message but only because it is Friday. If you changed the day to Monday you will still get the alert "It's Friday, but I don't have enough money to go out".

I could post the correct answer for you but I won't yet .... have another go testing that it is Friday or not & that you have enough money.

As a hint I think that you only need to make around 4 small changes to the starting code that you are given and think about equality, AND's & OR's

I hope that helps ....

Update: Ok, I can see that you are still asking for help in another thread so I will add my answer to the challenge

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.");
}
Jakob Wozniak
Jakob Wozniak
17,896 Points

Your code looks good, but it looks like you're missing a semi-colon after the "today" variable.

It should look like:

var today = 'Friday';

I hope this works!

Jakob Wozniak
Jakob Wozniak
17,896 Points

Actually, bothxp looks like he has the right answer. :P

:-)