Console is logging false when number = 3


#1

Here is the code I have:
var isEven = function(number) {
// Your code goes here!
if(isEven %2){
return "false"
}else{ return"true"
}
};

If I could have help with figuring this out it would be great.
Thanks!


#2

You are returning a string Value 'true'
instead of the required Boolean Value true
AND
in your IF-condition you should use a comparison suing the comparison-operator
like
number%2 === 0


#3

And as automatically correct :smile:
it should be number and not isEven. Because isEven is a function and taking the modulo of a function doesn't make much sense.


#4

var isEven = function(number) {
if (number%2===0){
return ("true");
}else{
return("false");
}
};
isEven(2);


#5

Remove the quotes from around true and false they are turning them into strings


#6

The problem is that non-empty strings are treated as true so both "true" and "false" act as true if for example a test function would ask for if(isEven(3))


#7

Thanks Bro :smile: it did solve the issue


#8

Thanks Bro :smile: i did get that after a while :smile:


#9

Thanks for that!
I really couldn't figure that out by myself.