12/14 Or Question


#1

I got the exercise correct but now I am playing with the code and I don't understand why this returns Nay.

var tired = false;
var bored = false;

var nap = function() {
if(tired || bored){
console.log("Yay");
} else {
console.log("Nay");
}
}
nap (tired,bored);

Since I set both variables as false, shouldn't it output Yay?


#2

Ok first of all if your function has no parameters feeding it with arguments such as tired and bored does simple lead to ignoring these arguments.

Also getting "Nay" is perfectly fine. The OR operator chains two statement together and is true if at least one of the two statements is true. As neither of them is true the whole statement is false and therefore you pick the else path.