'Oops, try again. Your function returns true for 3' #2


#1


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


So it says that it returns true with '3', and I don't even know how that is possible.

Screenshot: http://prntscr.com/ft3bdp


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


#2

lets see what the function actually returns:

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

console.log(isEven(3));

okay, so strings are considered true, good to know

isNaN returns true if number is not a number, when number is a number false is returned, now look at your condition


#4

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