2. If / else if / else


#1


var isEven = function(number) {

    if (number % 2 === 0) {
    return true;
    }
    else if (isNaN(NaN) === false) {
    return "That ain't a number!";
    }
    else {
    return false;
    }
};
isEven("yolo");


I need help why this is wrong, "Oops, try again. Make sure your if/else if/else statement returns a string when the function input isn't a number."

Thanks!,
ThatGoldenSteelix


#2

isNaN(var) returns True if var is not a number and returns False when it is a number. So you got that definition reversed.
Also, NaN is not a defined variable (where did you define it?). Your input is number and you need to validate if that is a number of not.


#3

i appreciate ur contribution to me accomploshing my work


#5

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