If/else code


#1

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

I don't know what is wrong with this code. the computer tells me "Oops, try again. Looks like your function returns false when number = 3. Check whether your code inside the if/else statement correctly returns true if the number it receives is odd." I know what If/else statements are and how to work them but I can't get what the Instructions want


#2

isEven is the name of the function. The conditional should be using the parameter variable, number...

if (number % 2) {
    return false;
} else {
    return true;
}

When number mod 2 is non-zero, the conditional will yield true, so the return value will be false (not even), else it will be true (is even).


#3

now it says the same thing but at the end it says "even" not "odd"


#4

Oh nevermind I didn't even bother to look at the rest of your example. lol thanks!!! @mtf


#5

tks
also helped me
i just figured out the bool:smile: