# Oops, try again. Your function returns true for 3!?

#1

This is my code :

var isEven = function(number) {

if(number % 2 === 0){

``````  return "ai un numar par";

}

else if(isNaN(number)) {

return "ai lovit isNaN ul";
}

else{

return "ai un numar impar";

}``````

};

isEven(3);

In the console i get the right things but i alos get an error every time.Please help.
This error:

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

#2

You need to use `true` and `false` for even and odd case not strings.

#3

That's the example code.

Why it's so....

Well small piece of code...

else if (isNaN(number)) {
return "it is not a number";
}
else {
return false;
}

var isEven = function(number) {
// My code is the most simple one???
if (number % 2 === 0) {
return true;
}
else if (isNaN(number)) {
return "it is not a number";
}
else {
return false;
}
};

#4

What is your question or problem with this one?

#5

The question was why do i get this error although in the console the result is the desired one....but i finally made it work.
Thank you

#6

@ibigspot
You get the error because 3/2 does not = 0 left over it has 1 left over.

Thats why there is an error.

for example 4 / 2 = 0 which is fine.

3 / 2 = 1 and 1 LEFT OVER which isn't === 0 like you stated.

This line is what I'm talking about. It's saying divide a number by 2 and it should have 0 left over but 3 / 2 has 1 left over which should return false not true.

#7

The problem is in the hint. It shows that the function return strings for all conditions. We referred to that.