1. If/Else


#1

Below is my code. It might look like the code of other people but I keep getting syntax errors. I don't see what I'm doing wrong, an someone please help me?

var isEven = function(number) {
// Your code goes here!
if(number % 2 === 0)
{
return true;
}
else if(isEven("number"));
{
return "Now What?";
}
else
{
return false;
}
};


#2

this line:

else if(isEven("number"));

that is one very dangerous semi-colon, it causes your else if to not execute correctly


#3

On your else if statement then the semicolon shouldn't be there, just curly brackets.


#4

I took that out and this is what I got - Oops, try again. It looks like you have an error in your code! See the error message for more: RangeError: Maximum call stack size exceeded


#5

Just as I spotted it and was about to post my answer then you posted yours :slight_smile:


#6

Could you please post the link to the exercise?


#7

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


#8

your else if has another problem:

else if(isEven("number"))

you call the function, which will mean the function will endless call itself. You should use isNaN to check if the number variable (variable, so no quotation marks) is a number


#9

Now I get isNAN is not defined. Where does it say to use that?


#10

I'm lost and confused at this point. I don't understand what it's asking for.


#11

why on earth do you even have else if? That is exercise 2, you are at exercise 1


#12

I took out the quotes and it just worked. Thank you all for your help.