If/if else/else


#1

https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/2?curriculum_id=506324b3a7dffd00020bf661#

var isEven = function(number) {
var newIseven = number % 2;
if (newIseven===0){
return true;
}
else if
(isNaN(number)){
return "number is incorrect";
}
else{
return false;
}
};
isEven(even);

after entering number i get the proper answer except when i enter any string i m not getting the return value "number is incorrect"


#2

when you all the function at the end:

isEven(even);

you should actually pas a integer (4 for example) as argument, not even


#3

then whats the use of isNaN function


#4

that is the question, ah yes, you can pass even into the function, but then pass it as string, or define a variable even which holds a string.


#5

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