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

Something's wrong with this script. The value in the variable money is only 9. But if you preview this script you'll see

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

//Fixed Code Presentation

2 Answers

josue exhume
josue exhume
20,981 Points

what you have to check here is your logical operator the way the OR operator works is, it checks if

if (left side || right side) { // if any of the sides is true the code execute the "then do this"
    then do this
} else if ( left side || right side){ // it move to this statement only if the first arguments we checked didn't return true
   no do this
} else {
  welp just do this instead
}

the AND operator checks to make sure both, the left and the right side are true before it executes the code

so or is if any of the sides is true then that statement your checking is true and is if both of the sides is true then that statement your checking true

i hoped this help.

heres the answer if your really stuck.

var money = 9;
var today = 'Friday'

if ( money >= 100 && today === 'Friday' ) { // used the and operator
  alert("Time to go to the theater");    
} else if ( money >= 50 && today === 'Friday' ) {// used the and operator
  alert("Time for a movie and dinner");    
} else if ( money > 10 && today === 'Friday' ) {// used the and operator
  alert("Time for a movie");   
} else if ( today === 'Friday' ) { // checks if today is friday and by default we know money is less then 10 because we checked for it earlier
  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.");
}

its not working,still show bummer.