Doubt in chp.9


#1


var isEven = function(number) {
  // Your code goes here!
  if(isEven % 2) {
      return true;
  }else {
      return false;
  }      
};
console.log(isEven);

Will somebody tell me what correction should be done in this code?


#2

here:

if(isEven % 2)

you should check if the remainder of number (the function parameter) equals zero.

This way, you can pass any value into the function call as argument to check if the number is even/odd


#3

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