1. If / Else


#1


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


This is my code. I don't get what the problem with this code is please help!


#2

isEven is the function, how does a function have a remainder?

if the remainder equals zero, i don't see the equals zero in your code


#3

well it should get true if the remainder = 0 so your code should be
if isEven % 2 == 0:
return True
else:
return False


#4

isEven is the function, the remainder of a function divided by 2 is an error.

modulo can only be used for numbers


#5

var isEven = function(number) {
// Your code goes here!
if (number%2===0){
return "true";
} else if (isNaN(number))
{ return "false";}}
isEven(3);


#6

Is there something i can help you with? Do you have a question, problem and or error?


#7

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