# I have a problem in 9. More on control Flow - 1. if /else

Can anybody tell me how to pass this. If can write down an example, I will be very thankful.

@gigablaster70715
Can we have your code and details from the exercise please? That will be very helpful if we want to understand your problem.

1 Like

@limitless24
Here, you are trying to use the modulo on the function isEven you are creating. In the instructions, it tells you to test if the number put in parameter when you will call the function is evenly divisible by 2. So instead of isEven inside of your if statement, write number(which is the parameter the user needs to input to test whether the number is evenly divisible by 2) instead of isEven. Hope this helped you.

3 Likes

thank you that was it

In addition to this number%2 would give you a value of 0 or 1, so 0 is equivalent to false and 1 to true which is kind of contradicting towards what the exercise expects to see for even and odd numbers. So instead of relying on those side effect values better check for number%2 === 0 instead. Hope this is not too confusing.

1 Like

I have the same message all the time when I put an odd or even number when I call the function

Hi a number is even if the remain of is division is equal to 0 when it is divide by 2 so your if condition should be like that

``````if (number % 2 === 0)

``````

You should use % which gave the remain of the division .

Thanks ! (I thought it was the same , evenly divisible by 2 = divisible by 2 ) .

Sry for the late response just to make this clear:

dividing by 2 would e.g. for 3/2 yield 1.5 which is a number `> 0` and as you can read here:

All numbers except 0 are treated as true when used in a condition. So this might explain the problem, does it?
On the other hand % gives you the remainder of a division e.g. 5%2 is 2 because you can fit 2 whole 2s in 5 and a remainder of 1 as you cannot fit 2 in 1 using integers. So what you get from 5%2 is the remainder of 1.

It says I got the lesson correct, because I followed the advice of these columns, but it isn’t returning anything like it should be.

My syntax:

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

};

Any ideas on how to fix this?

Hi try to call the function isEven with a number

thanks! it worked! I may be able to remember that for next time.

Also, this syntax is apparently not working even though I followed the directions: