12 or operator is false but should be true


#1


The code returns false.

Why is it not returning true, since one or both of the variables 'tired' and 'bored' are true? When I set tired=false and bored =true, it returns true.


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

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


#2

because you just declared your function.you didnt call it.without calling the function will not work.

call it after closing the function.like

nap() // called with function name

or inside of console.log

console.log(nap())

and the result (false) you are getting it was just the last value(bored = false;) you added .


#3

Thanks. I was very tired.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.