Lesson 1


#1



Oops, try again. It looks like you have a ReferenceError. Maybe you forgot to define a function named isEven?


var isEven = function(number) {
  if (isEven % 2 = 0) {
      return true;
  } else {
      return false;
  }  
};
isEven(2);


#2

Two problems:

  1. You have to check in the if condition a number and not the isEven function itself.
  2. There is a difference between = and ===. Do you know it? :wink:

#3

Hi, @enxin.

Please not the following piece of code:

1) Your if condition (if) is trying to call a function variable (isEven) that is the same one your condition is in (var isEven = function () {};). That's recursive.

You should check if the module (%) of the variable provided to the isEven function (number) divided by 2 is equal to 0 and not the function itself (isEven). Is that clear to you?


Please note the following code:

2) Also under your if condition, you are attributing the 0 value to the result of the module of a variable divided by 2 instead of checking if it's equal to. You are saying what you think should be the result instead of asking if the result is 0.

When you type "var i = 0" you are saying to JS that the variable i has the value of 0.
When you type "var i == 0" you are saying to JS that it should check if the value of the variable i is zero.

Please let me know if this explanation helped you. If so, please check the "Solution"button at the end of this comment to close this post as solved.

[]s