Why is this happening?


#1

var isEven = function(number) {
if (number % 2 === 0) {
return true;
} else if (isNaN(number)){
return "You did not input a number!";
} else {
return false;
}
};

isEven(12);

I know that the above code works, and lets me continue in the lesson. but....

I tried to be a little more creative, and i'm curious if this would work and i'm being denied because of the lesson or because of my code? I really want to figure this out it's bugging me!

var isEven = function(number) {

if (number % 2 === 0) {
return "Your number " + number + " does in fact divide evenly by 2";
} else if (isNaN(number)){
return "You did not input a number!";
} else {
return "Your number " + number + " does not evenly divide by 2!";
}
};

isEven(prompt("Input a number to see if it is divided evenly by 2"));

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

Thank you in advance for your help!


#2

@gmunker

What did you try to input for the prompt?


#3

12 (sorry knew i was forgetting something)


#4

its working ok in jsbin.com, and google console, thats why i raise the question is it just a lesson error? Are they looking for something specific or is it the code.


#5

@gmunker

I think your code works fine. It may be the lesson's instructions not requiring you to do it.