Else/else if /else./more on control flow/ Stuck


Why does it output the string "You input is not a number" two times??

var isEven = function(number) {
// Your code goes here!
if (number % 2===0) {
return true;
else if (isNaN (number)===true) {
console.log ("You input is not a number");

 else {
     return false;




Hi the isNaN should be like that
else if (isNaN(number)) { return "You didn't put a number!" }


I know that but why does it write the sentence 2 times when I put control.log (shouldn't it write just one time)??


I think that's because you call it at the end isEven("me");


You can test if it's something other than your code causing the print, by adding a print that marks the end of when your code runs.

console.log("=== Any prints below this one is none of my doing ===");


That and also I think because console.log() will always print out the string even if the condition is not true. So when the condition is true it prints the string the times (command console.log() and because of the function).


Thanks guys for the help I got it now and @ionatan thanks for the tip :smile: