Logical


#1

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

var nap = function() {
// Add your if/else statement here!
if(tired || bored === true)
{
console.log("true")
}
else
{
console.log("false")
}
};nap(tired,bored);

Oops, try again. It looks like your function doesn't return false when tired and bored are both false.


#2

HI your console.log() should be return statement and remove the " " around true and false


#3

even though the condition fails how it comes inside else condition and prints false..


#4

look at this code:

if (x == 5 || y == 6)

you need to do comparison on both the left and right handside as i did above

How can your function call have parameters while the function doesn't have parameters? remove the function arguments from your function call


#5

as per instruction given i have globally declared true and false

var tired = true;
var bored = false;

if(tired || bored === true)
{
return true;
}
else
{
return false;
}

how to check the if condition as u mentioned


#6

since you work with booleans you might get away with it, but you should actually compare at both sides of the || operator (like i showed you)

I said you should remove the arguments from your function call (since the function doesn't have arguments), not the function and function call itself


#7

no...no...IN shortly i written here..But i did wat u said...


#8

normally you would have to compare at both sides:

if(tired === false || bored === true)

but given you use boolean values at the moment, you can also decide not to compare:

if(tired||bored)

but it looks so weird if you just compare at one side of the or operator


#9

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