If/else if/if more on control flows


#1

var isEven = function(number) {
// Your code goes here!

if(number%2===0) {
return true;

}
else if(isNaN(number)===true){
return "input isn't a number";
}
else{
return "false"
}

};
isEven("hai")
may i know what is the mistake in above code its showing your code returns true fo r3!


#2

here:

else{
return "false"
}

you return a strings, strings are considered true, you should return a boolean value instead


#3

oh thank u i got it
my mistake


#4

It would be a miracle if you didn't make mistakes :wink:

That is why we have to forum, so you can get help to learn from your mistakes and become a better programmer :slight_smile:


#5

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