2. What's wrong with my code?I'm getting SyntaxError: SyntaxError


#1

Whenever I try to input my code I get a SyntaxError: SyntaxError.
This is my code.

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

Please help. Thanks.


#2

The Javascript isNaN() method needs a so-called argument
which in our case would have been the number variable
like

isNaN(number)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN


#3

I just tried changing it to this

  }else if(isNaN(number)){

It still isn't working. :confused:


#4

You are using a semi-colon-; on you IF ELSE-IF ELSE statement structure....
A semi-colon-; is an End-of-Statement indicator for the Javascript-interpreter

var isEven = function(number) {
   // Your code goes here!
   if(number % 2 === 0){
      return true;
   }else if(isNaN(number)){
      return "Your statement was not a number! /:(";
   }else{
      return false;
   }
 };
 console.log(isEven(4));
 console.log(isEven(3));
 console.log(isEven("a"));

#5

Thank you I finally saw where the Error was and my code works now. :smiley:Thanks again.