Am I being stupid?


#1


I am going through the code and the error is saying that when the number = 3 it returns false. Surely it should return false as I am searching for an even number, and 3 is an odd number.


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


#2

you should return boolean values, not strings

if the remainder of divining a number equals zero, its an even number. You never check if the remainder equals zero?


#3

I just amended the code as seen below, and it still says that it is returning the wrong text

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

else {
return "false"
}
};


#4

The error that appears is as follows:

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.


#5

you return a string, strings are considered true.

return boolean values


#6

Ok, how do I do that?


#7

change the string into boolean values? If you don't know the difference, check documentation/earlier exercise, this was in the first track and has come many times.


#8

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