# 1 If / else

#1

I have problem with my code. When I hit Save & Submit code it says "Oops, try again. Looks like your function returns false when number = 2. Check whether your code inside the if/else statement correctly returns true if the number it receives is even."

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

#2

Instead of isEven you have to write number in you if-statement.

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

#3

Hey, sorry for being a little thick here, but why do we use number instead of isEven?

#4

Because the function isn't going to be divided by 2. you cant divide a function by 2

#5

Hi,

Would you please be able to explain this part of the code?

if (number % 2 === 0 ){

I'm reading this as === false, and isn't making a whole lot of sense to me at the moment

Thanks!

#6

It's checking to see if the number given is divisible by 2 with ZERO left over. An example that would pass would be 6 because it's divisible by 2 with no left overs.

7 % 2 would = 1 because 7 divided by 2 is 3 with one left over which would make it fail the test.

#7

That makes much more sense!

Thank you