What is wrong with this?


#1
var isEven = function(number) {
  // Your code goes here!
 if(number) {
    return number % 2 == 0;   
 } 
 
 else if(isNaN(number)) {
     return "Not A number";
 }
 else {
     return false;
 }
};

isNaN is killing me
#2

The return value will always be correct, but the else clause will never be read.

if (number) {
    # will return `true` when number is even
    # will return `false` when number is odd
}

If you wish to utilize the entire control flow structure, write the even test inside the condition:

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

#3

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