I think many people can get confused as to whether why their code is wrong, in this case, I got confused thinking about what error I had possible made while writing it. The problem:
If both conditions evaluate to true, then console.log() the string 'time to sleep'
So me, being a grammar nazi wrote:
Time to sleep.
The same happened with:
Otherwise, we should console.log()'not bed time yet'.
It’s not something THAT big of a deal, but I think you guys could at least make both versions (The one with lower case and the one with upper case) pass, no matter what.
The tutorial needs to be checked for syntax. There are various points in which we are not putting semicolons in our conditional statements, then an example will show one in the conditional. Then there is an example where they put a semi colon after an else statement’s closing curly bracket.
Hi guys! I was playing around with the logical operators and given this:
let mood = 'sleepy';
let tirednessLevel = 6;
if (!mood === 'sleepy' || !tirednessLevel<=6) {
console.log("time to sleep");
} else {
console.log('not bed time yet');
}
why is it returning ‘time to sleep’ and not “not bed time yet”?
I’m sorry to drag you back sir, but I still don’t quite understand. Since the if block came back as false, then the else string (‘not bed time yet’) should have been executed, but it didn’t. How come?