Function return issue with isNaN()


#1


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

Hello everyone!
I have been trying to run the code below but I get the following error:
"Oops, try again. Your function returns true for 3!"
I have tried both if/else if/else and the ternary and I still get that same issue. The function returns the right answer every time given different data types but I still get that error. Any assistance would be much appreciated. Thanks!


var isEven = function(n){
    var result = isNaN(n)? "Not a number":(n%2===0? "Even":"Not even")
    return result;
    };

isEven('3');


#2

First of all you should always follow the instruction.

read the instruction again.you have to add an else if branch to your existing code.

now come to the point your function should return true for even number and false for not even.

so instead of string value you have to return boolean value.


#3

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