Trying to console.log an "or" function


#1


Exercise 12 "Or" in "more on control flow"


Hello I want this code to console.log different messages when the nap function returns true or false. I don't know why my "screen" function isn't console logging anything.
please advise


var tired = false;
var bored = true;


var nap = function() {
  if(tired || bored) {
      return true;
    }else{
          return false;
      }
  
};
var screen = function(){
    if(nap = true){
        console.log("take a nap");
    }else{
        console.log("awesome energy");
    }
    
};


#2

var tired = false;
var bored = true;


var nap = function() {
  if(tired || bored) {
      return true;
    }else{
          return false;
      }
  
};
var screen = function(){
    if(nap === true){
        console.log("take a nap");
    }else{
        console.log("awesome energy");
    }
    
};

screen();

Because you didn't call function screen(). Also here

 if(nap = true)

Here you need to use comparison operator == or ===, but you used assigned operator =.


#3

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