Issues with isNaN(number)


When I run this code, it always logs "Not a number" regardless of whether or not the argument is a number or not.
If the argument is a number, it will still log "Not a number" and then either true or false.
If the argument isn't a number, it logs "Not a number" twice.
Anyone know what's wrong with this and how to fix it?

var isEven = function(number) {
    if (number % 2 === 0) {
        return true;
    else if (isNaN(number) === true) {
        console.log("Not a number");
    else {
        return false;


The thing to get away from very early on is comparing a boolean to a boolean. It is a moot comparison.

if (true === true)

is akin to

if (true)


Try using return instead of console.log since it is what they wanted in the instructions.


Replaced console.log with return and it's working now.
Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.