Reference Error


#1

Hey everyone, I keep getting a reference error, saying that isEven is not defined, but I thought it being a function(number) defines it? Can someone tell me how to define it and maybe what to define it as? Thanks in advance!

var isEven = function(number)

{
if (number % 2 = 0)
{
return true;
}
else
{
return false;
}

};


#2

Hey @brocktikson! The reason your getting the reference error is because here:

Your not comparing it but assigning it... Meaning assinging is one equal sign and comparing is two.

So when you assign a value you use one equal sign like this:

var value = 3;

But when you compare you use two equal signs like this:

if(value==3){
return true
}

So just change your code to this!:

var isEven = function(number)
{
    if (number % 2 == 0) {
        return true;
    } else {
        return false;
    }

};

Hope this helped!


#3

yes! that worked perfectly, thanks for the explanation!