Javascript-If / else if / else


#1

hiii
someone can help me with this, i need to use IsNaN function for check put into the function is not a number at all:

var isEven = function(number) {
// Your code goes here!
if (isNaN("number")) {
return "some string"
}
else if (isNaN(false)) {
return "another string"
}
else {
return "yet another string"
}
};
isEven("michael");


#2

False is a boolean. Therefore, you can not use 'false' in here. When returning the things, you need to do either true, or false:

Example:

return true

return false

-----------------------------------------------------------------

The instructions say to:

If the number put into the function is not a number at all, instead of return true; or return false;, the function should return a string that tells the user that their input isn't a number. (This string can say whatever you like.)

This is saying that for the else if statement, to return a string that says that the input isn't a number.

THEREFORE:
if and the else statements must be used by booleans(True or False).


#3

like this:

var isEven = function(number) {
// Your code goes here!

if (number%2==0) {
return "some string"
}
else if (isNaN(number)) {
return "another string"
}
else {
return "yet another string"
}

};
isEven("fdfd");

????


#4

You need to change:

return true

Change this also:

return false

ALSO

I suggest taking out this:


#5

Closer...

var isEven = function (number) {
    if (number %2 === 0) {
        return true;
    }
    else if (isNaN(number)) {
        return "Not a Number!";
    } else {
        return false;
    }
};
isEven("nil");  // Not a Number!

#6

thank you very much!!!!