What is wrong with this code?


#1

var isEven = function(number) {
// Your code goes here!
if (isNaN(number)) {
return "only numbers";
}
else if (number % 2 === 0) {
return "Even";
}
else {
return "Not even";
}
};


#2

getting the same error YOUR FUNCTION IS TRUE FOR 3!


#3

The problem is you have to return true or false except when the isNaN block is true then you return some text

var isEven = function(number) {
                    // Your code goes here!
                if (isNaN(number)) {
                    return "only numbers";
                }
                else if (number % 2 === 0) {
                    return true;
                }
                else {
                    return false;
                }
            };
console.log(isEven("5ty"));

you can also click here
click to got to labs


#4

Thanks problem solved


#5

var isEven = function(number) {
if(isNaN(number)){
return "not a number";
}
else if(number%2===0){
return true;
}
else{
return false;
}
};
console.log(isEven(89));