Your function returns true for "3"


#1


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

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");
          }else{ 
        return("false");
        }
    }

isEven(3);


#2

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.


#3

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