Your function returns true for "3"


When I run this code, it tells me that it returns "true" for 3, and when I run the code with three, it returns "false". How can I improve my code or is there something wrong?

var isEven = function(number) {
    if (isNaN(number)) {
        return("invalid number")
    else if (number % 2 === 0) {
        return ("true");



There's a difference between "true" and true. The first one is a string (a sequence of characters), while the second one is a boolean (true or false).

You are expected to return the latter instead of the former.

Same goes for false.


remove brackets and quotes from true and false
return true;
return false;
and theres no need for isEven(3); so delete that line