This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by mattdonato
over 11 years

I have no clue whats wrong with my code.

var isEven = function(number){

if(isEven % 2 === 0){return true;}

else{return false;}

};

isEven(4);

Answer 50c11a7b432535ae66000b27

3 votes

Permalink

Your problem is that you put the name of the function in your if statement. You need to swap this for the ‘place holder variable’. That is what ever is between brackets of the function. In this case it is “number”. This temporary variable then gets swapped for whatever number you enter between the brackets when you call the function.

e.g.

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


isEven(4); 

``//temporaryVariable gets swapped for the number 4. Then it runs the function with the number 4 instead.

points
Submitted by Sharma
over 11 years

3 comments

mattdonato over 11 years

Thank you it works now.

devananda about 11 years

best explanation I’ve seen about this (personally)

rApt0rAWSMsawce about 10 years

Thanks for the help, I had the exact same problem and this was the first one I tried…. thanks :)