Snif... What am I doing wrong?


#1

Hi,

Here is my code:

var isEven = function(number) {

var typenombre=isNaN(number);

if(typenombre==='false')
    {
    
    var nombre= number%2;
    
    if(nombre==0)
     {
         return true;
    }
    else {
     return false;  
    }
    }

else if(typenombre==='true'){
    return 'Merci dentrer un nombre';
}

else{}
}

It says: Oops, try again. Your function returns false for 2!...

What am I doing wrong? Thanks!


#2

you need to out something in your last 'else' statement ; you put %2 to get false


#3

My last else wouldl not out anything. Typenombre can only be true or false.


#4

you need three equation signs, not two


#5

two are actually ok 2 compare the value and 3 compare value and type.


#6

hum... So no idea why it is wrong?


#7

First of all else is not mandatory so if you don't need the else case just omit it. And the other thing is that your parameter is named number but in the progress you mostly use nombre.


#8

Hum. Basically, you don't know why it is not working?


#9

... Sry completely missed that one ... :blush:
Next guess would be that typenombre is a boolean meaning true or false and not "true" or "false".


#10

in your if statement checks you need to put false and true without quotation marks. You turned booleans into strings.