2. If/else if/else


I need some help, even if my code shows every return I want, this error still occurs:

"Oops, try again.
Your function returns true for 3!"

var isEven = function(number) {
  // Your code goes here!
    if(number % 2 === 0){
          return "A variável é um número divísivel por 2";
    } else if (isNaN(number)){
        return "A variável é uma string";
    } else {
        return "A variável é um número não divisível por 2 nem uma string.";



Could you provide the link to the exercise.....


Here's the link:



Try it with

var isEven = function(number) {
if(number %2 === 0 ){
 return true;
else if (isNaN(number)) {
 return"Is not a number";}
else {
 return false; 


Funny thing, it worked.

Can you explain me why? I'm a bit confused, mostly because the exercise tell us to return a string in all of them.


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