12. or


#1

For some reason I am getting an error:
Oops, try again. It looks like your function doesn't return false when tired and bored are both false."
I have "!" before tired to make both false, any suggestions?

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

var nap = function() {
if (tired || bored)
{
return "That is correct!";
}
else (! tired || bored)
{
return "Correct it's false";
}

};

nap();


#2

your else block should be empty. It should just say

else
{
return "Correct it's false";
}


#3

Thank you for the quick answer, :frowning: it still gives me the same error for some reason


#4

Hi @h3llokitty,


  • An else statement does need a condition, it basically just runs if the IF condition is not met

  • you can remove (! tired || bored) from the else part

  • then you should not return a 'string' but rather a boolean (true/ false)

added some /*comments*/ to your code to further show you where can modify it:

var tired = true;
var bored = false;
var nap = function() {
if (tired || bored)
{
return "That is correct!"; /*replace with return true;*/
}
else (! tired || bored) /*remove (! tired || bored)*/
{
return "Correct it's false"; /*replace with return false*/
}
};
nap();

#5

@rubylearner03 is correct. the reason you got those errors is because you didn't return booleans. you need to return true or return false in the if/else blocks


#6

Thank you for your help :smile: