More on Control in JS- Problems with 12: "Or" Lesson!


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/2/3?curriculum_id=506324b3a7dffd00020bf661


The truth is, I'm not sure if I understand what they are asking of me. My error says "Oops, try again. It looks like your function doesn't return false when tired and bored are both false." But why is this the case? Please help!


    // Declare your variables here!
    var tired = true || true;
    var bored = false || false;


    var nap = function() {
      // Add your if/else statement here!
      if(tired || bored) {
          console.log("Yeah, me too.");
      } else if(!(tired || bored)) {
          console.log("So, what do you want to do?");
      }
    };


#2

@yoshicodes

Your code

The instruction

Don't use || comparator sign because you need both of them to be false so we use && comparator sign. || comparator sign is for or so it doesn't matter if the second is not right but the first one is right, it will still execute the code in the curly brackets.


#3

Thank you, I tried to change to the && and for some reason, I'm still having problems. Is there anything else missing?

var tired = true || true;
var bored = false || false;

var nap = function() {
// Add your if/else statement here!
if(tired && bored) {
console.log("Yeah, me too.");
} else if(!(tired && bored)) {
console.log("So, what do you want to do?");
}
};


#4

Here's what worked for me!

var tired = true || true;
var bored = false || false;

var nap = function() {
if (tired || bored) {
return true;
} else {
return false;
}
};


#5

Thank you so much for this!