2. If/Else If/Else


#1

What needs to be corrected here? Many thanks.

var isEven = function(number) {
// Your code goes here!
if (number % 2 === 0) {
return true;
}
else if (isNaN(number)) {
return ("This is not a number");// Do something else
}
} else { // Otherwise
return false;// Do a third thing
}
}


#2

This will do :smile:

var isEven = function(number) {

if(number%2===0){

 return true;

}
else {

 return false;

}

};
isEven(2);


#3

What is it complaining about and what exercise does this belong to? As there are two similar once at the beginning of this lessen and it seems like @tagrunner21344's code is meant for the other one.


#4

I'm having trouble with exercise #2 not #1.

Thanks again for the assistance from all parties.


#5
var isEven = function(number) {
  // Your code goes here!
if (number % 2 === 0) {
    return true;
} 
else if (isNaN(number)) {
    return ("This is not a number");// Do something else
}
} // <-- This one is too much and closes your function too early

#6

Um i may be missing something but are you forgetting the semi-colon after the last bracket?