Why am I getting error?


#1

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

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

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


Replace this line with your code.


#2

you should return Boolean values, you return strings, remove the " around false and true


#3

I tried that already but received same error.
Looks like some issue from code academy.
Now same code works.


#5

your else missing a few curly brackets ({}). if, else if and else should all have curly brackets:

if (condition){

} else if (other condition){

} else {

}

if problems persist, post an updated version of your code


#6

If you have a single line of code for the body part of else/if/else if, you can skip the braces.
However, the code works now.
Thanks for your help. :slight_smile:


#7