Write an if / else statement inside the isEven function



Write an if / else statement inside the isEven function. It should return true; if the number it receives is evenly divisible by 2. Otherwise (else), it should return false;.

Make sure to return - don’t use console.log()!

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I think this exercise is incorrect. In the instructions it is asking for you to return true if the number received= even, however after submitting my code below which does exactly this I am getting an error that says “Looks like your function returns false when number = 3. Check whether your code inside the if/else statement correctly returns true if the number it receives is odd.” This is correct because “3” is an odd number so according to the original instructions my code SHOULD return false when number=3 .

var isEven = function(number) 
  // Your code goes here!
  if (number % 2 === 0)
      return ("true");
      return ("false");


the error message should be:

Looks like your function returns true when number = 3

the problem is that your function returns strings, not boolean values. “false” (the string) is considered true


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