More on Control Flow in JS 2/14


#1


More on Control Flow in JS 2/14


My code doesn't return "That's not a number!" when put in isNaN("berry")


var isEven = function(number) {
  if(number % 2 === 0){
      return true;
  }
  else if(isNaN(number) === true){
      return "That's not a number!";
  }
  else{
      return false;
  }
};


#2

Hey, I took a look at this code, and from what I can see there's nothing wrong with it. It runs as expected in my editor as well. Did you remember to call it like so:

var isEven = function(number) {
  if(number % 2 === 0){
      return true;
  }
  else if(isNaN(number) === true){
      return "That's not a number!";
  }
  else{
      return false;
  }
};

isEven('berry');

If it still doesn't work after that, I'd recommend reporting it as a bug.


#3

Yeah it just keeps returning 'true'

but thanks for the help!


#4

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