I dont see my error


#1

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


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

};
isEven(6);


#2

if the remainder of number divided by two equals zero, return true

the equals zero bit is missing in your case


#3

thanks for the help!


#4

look at/run this code:

if (0){
    console.log("0 is true")
} else {
    console.log("0 is false")
}
if (1){
    console.log("1 is true")
} else {
    console.log("1 is false")
}

if the number is even, the remainder is zero, so the condition is false, else runs. When the number is odd, the remainder is one, the condition is true, so if runs.

So you don't have to check if the remainder equals zero, but then you have to swap return true and return false around

If this makes sense, very good, if not, just move on :slight_smile:


#5

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