If/Else strange error?


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1?curriculum_id=506324b3a7dffd00020bf661

Hi,

i have a strage issue with this exercise. because the error message seems to contradict the instructions.

The Instructions say:

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

So far so good, but then I get the error message:

Oops, try again. 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.

So yes, my code outputs FALSE if you enter the number 3, since 3 is not evenly divisible by 2. But thats exactly what the instructions asked me to do, or am I completely lost in translation here?


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

isEven(3)


#2

Do not write quotes around boolean primitives.

true
false

#3

remove the quotes from true & false


#4

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