Unable to rectify the mistake in given code. Error given below


#1

Error: Oops, try again. Make sure your if/else if/else statement returns a string when the function input isn't a number.

var isEven = function(number) {
// Your code goes here!
if((number%2)==0){
return true;
}

       else if(isNaN(NaN) == false){
          return "Not a number";
           }

       else{
        return false;
        }  
      };

Replace this line with your code.


#2

the word you input to the function is 'number' not the 'NaN' , change it and you'll make it.

var isEven = function(number) {
 // Your code goes here!
if(number % 2 === 0) {
    return true;
} else if(isNaN(number)) {
    return "sth.wrong";
}
else {
    return false;
}
};

#3

Still error : Oops, try again. There was a problem with your syntax.


#4

Could you please post your updated code?


#6

I got the bug. I forgot the closing braces for the function.


#7

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