Unexpected token )?


#1


Hey can anyone help me with something? I want to know about two things:
First:Can someone tell me what the following code actually does?
Second:It says there's an "unexpected token )", and I do believe it's the closing condition bracket for the else if statement (I ran some experiments to find out) I just don't know how to fix the syntax.


 
var CoolKids = "HI THERE!";

function India() {
  if (CoolKids % 2 == 0) {
      return true;
  } 
  else if ( isNaN(CoolKids); == true ) {
      return "BRO THATS NOT A NUMBER";
  }
  else {
      return false;
  }
};

unexpected token )


#2


else if ( isNaN(CoolKids); == true )
`
I would think the unexpected token is simply the semi-colon after the (CoolKids).

Since CoolKids is assigned to a string. Calling the function India:
India (CoolKids);
// will return as "Not a number" Only


#3

Thanks! I still have a few questions though. I was actually trying to focus
on the isNaN syntax because I was just introduced to it. I wanted it to do
this: if isNaN equals true (if the variable India gets detected as no
number) Then you would return "bro that's not a number". Is that the right
syntax for that?
Also, even before I added that semi colon it was showing the "unexpected
token )" thing. Thanks for the help!


#4

Yes I believe it to be correct

In the function India:
If coolkids is not a number (which it is not becuase you have assigned it a value of "Hi there") it will return true and hence it will return return the string "...not a number"

and does this work without that semicolon now? Ive run the exact same code (minus the semicolon) of yours without any errors on my console.


#5

Wow that's awesome! Thanks!


#6

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