1. If/else



This code keeps on giving me false if the number is the same as the divisor

"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."

Don't know what I've done wrong

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


In the condition after the if you're not using proper condition syntax. Instead of "number % 2" write "number % 2===0".


ok it works but why exactly should i do that? i still don't get the differences between the equal signs


Because when you're writing "number%2" you're not checking whether the number is even. When you're writing "number%2===0" you are. The modulus function focuses on the remainder, and an even number divided by two always returns a zero. Hence why it's true.

Also when you use "===" you're comparing and when you use "=" you're declaring.


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