2. If / else if / else


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/2?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. Your function returns true for 3!

help, what s wrong? :confused:


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


#2

else if(isNaN( isEven ))

you are checking whether function is a number or not


#3

Hi,
this part of the code is wrong "else if(isNaN( isEven ))" as isEven is a function, not parameter. the right code is "isNan(number)"

here is mine. hope it can help you

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

if(isNaN(number)){
return "that is not a number";
}

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

else{
return false;
}

};

isEven("mama");


#4

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