Debug this please


#1

var isEven = function(number) {
isEven = 44
if(isEven/22) {
return(true);
};
else{
return(false);
};
else if{ isNAN(isEven);
return("■■■■ yoself");
}

};


#2

Says unexpected token else


#3

else if should be before else.


#4

Did that before, ineffective.


#5

can you provide the exercise url?


#6

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


#7

uhm... i am afraid you will have to ask someone else. This is the code provided by the exercise, you haven't done much debugging. Good luck!

I can help you, but you will have to do something as well


#8

var isEven = function(number) {
isEven = 44
if(isEven/22) {
return(true);
};
else{
return(false);
};
else if(isNAN(isEven); ) {
return("■■■■ yoself");
}

};
same Syntax error persists.


#9

your else if is still after your else.
this line:

isEven = 44

you set the function to 44? Not sure that is a good idea
this line:

if(isEven/22)

dividing the function by 22? Not sure that is a good idea
this line:

else if(isNAN(isEven); )

isNAN is not the build in function you learned, and that is a very dangerous semi-colon


#10

var isEven = function (isNaN(4); {
isEven = isNaN
if(isNaN/2) {
return(true);
};
else if{
return(false);
}; else(isNaN){
return"■■■■ yoself";
};

};
Still not happening. SyntaxError ( unexpected


#12

the syntax error you currently have is from here:

var isEven = function (isNaN(4); {

that is a very dangerous semi-colon, and the number of brackets isn't matching (two opening brackets vs one closing brackets)

Take a moment to think how the program should look in the end


#13

@dataninja43387

You really should clean up the language in code that you share. That's not pleasant, especially as it seems to be intended to be rude.

else can only come as an optional part of an if-statement. If you end the if-statement with ;, then you can no longer have an optional else part. I suggest finding some examples of if-else's by searching the web.

It is usually useful to know where the error was raised. The js exercise environment doesn't provide line numbers, but most other interpreters do. The line number of where the error was raised isn't the full story of what's wrong, that's something you have to figure out as the programmer. But it can be useful information, so run it somewhere else for a more verbose error message. (your browser, nodejs, some online interpreter)


#14

Thanks, youtube helped