2.if/else if/else printing


#1


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


Hey guys, I passed the lesson, but my return function isnt printing to the console. What can I do to fix this?

var isEven = function(number) 
{  
if (number%2 === 1){
return true;

}else if (isNaN(number)){ 
    return ("Not a number");

 } else {
return false;
}
};
isEven = "cowwww"


#2

Problem1.

if (number%2 === 1)

To check if a number is even or not , The modulo should give 0.
Thus conditional comparison statement would be
number%2 == 0

Problem2.
isEven = "cowwww"
isEven(number) is a function that takes anything as argument inside the bracket.
like this
isEven("cowww")

so we don't equate but put argument inside the brackets!


#3

Awesome! Thanks a ton!


#4

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