What's wrong with my code?


#1



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

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

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

isEven(10);


#2

@jozsefrealtyyahoo.co

isNaN is a function that has parameter like this:

functionName(optional parameters);

In this case, the parameter that we will input is number.


#3

I don't understand, what is the solution?


#4

HI what @miniapple8888 mean is that you should put inside isNaN() the argument number

else if (isNaN("here put the argument number")) {
      return "That's not a number!";
          }

without " " around number


#5

I all so seem to be getting that same error message, as well. Can you guys see what is wrong with my code? I keep getting the you r function return true for 3.

var isEven = function(number) {
// Your code goes here!
if (number%2===0) {
return true;
} else if (isNaN(number)) {
return "Is this right?";
} else if (isEven) {
return "Some string"
} else if (isEven) {
return "Another string"
} else {
return "Yet another string"
}
{
return false;
}
};
isEven(10);

Thanks in Advance! ^^


#6

HI don't post on an old post 18 days later newxt time create a new topic with you code

then

you don't need of this part

else if (isEven) {
return "Some string"
} else if (isEven) {
return "Another string"
}

then your else statement should return true then you also don't need of this part

{
return false;
}