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

Why is my super conditional challenge not working?

var money = 9; var today = 'Monday'

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

10 Answers

Right, right. So you need to do it without changing the variables. The or operators should be and operators and the last else if block should test if it is indeed Friday, but you have less than 10 money.

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

Hope this helps.

Ayaz,

This code seems to work as expected. What are you trying to accomplish?

var money = 9; 
var today = 'Monday';

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

Stephen,

According to the instructions, I have to run the code to where it states, "It's Friday, but I don't have enough money to go out." I'm on the last objective in the JavaScript Basics section. I was told I have to fix the code.

I'm not sure what to tell ya buddy. That's exactly what the code is doing for me as it is.

The only difference is that the sentence ends with a period.

What was your code?

var money = 9; 
var today = 'Monday';

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

I think I made a mistake somewhere in the code.

Maybe mine is not working because both of my conditions have to be true instead of just one of them.

Well, if that's the case, then you need to use an and && operator, not an or || operator.

Stephen,

Did you send me my code or yours?

I'm not sure what challenge you are on. I was just reading your code to see if it works.

I did use an and operator.

I'm on the Super Conditional Challenge under the section titled Making Decisions with Conditional Statements. It's in the JavaScript Basics section.

Thank you.