Oops, try again. Your function returns true for 3!


#1


anybody know how resolve this problem ?!


var isEven = function(number) {
  // Your code goes here!
  if(isNaN(number)){
      
      return "Is not a number"
  }else if(number % 2 === 0){
      return "ok"
  }else{
      return "Is a number"
  }
  
  
};
isEven("3");


#2

you should return boolean values when the number is odd/even, not strings


#3

now i do this

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

And return this Error now!
Oops, try again. Your function returns false for 2!

I cant understand what this question want
https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/2?curriculum_id=506324b3a7dffd00020bf661#


#4

you need to return true when the number is even, and false when the number is odd


#5

i did this in the previous Question ( if / else )
this one is ( if / else if / else )
he ask to use isNaN() method


#6

then why change it? all the exercise ask you to do, is to check if the function input might not be a number in which case you should return a string, informing them that there input is not a number.

You shouldn't have change the true/false for even/odd numbers


#7

change the to false because that needs to boolean type as well


#8

i already tried
the same error Oops, try again. Your function returns false for 2!


#9

Can we see an updated version of your code?


#10

ok I had the same problem maybe go check out my longest topic


#11

here

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

#12

great .. I had thought it was to return String to all of them (if / else if / else)
I put them back again and It Worked.. Done !

thanks!


#13

no, returning string was only when function input is not a number, as mentioned in the instructions, no need to change the rest of your function


#14

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