Lesson 1. If/Else


#1

I honestly don't see what's wrong.
This is the link: https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1?curriculum_id=506324b3a7dffd00020bf661#
Error: Oops, try again.
Looks like your function returns false when number = 2. Check
whether your code inside the if/else statement correctly returns true if
the number it receives is even.
Code:

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

#2

this line:

if (isEven % 2 === 0)

the remainder of a function is most likely not 0. I would check if the remainder of number (your function parameter) is zero


#3

10 % 2 has a remainder of zero. So why is it not passing?


#4

because your condition is wrong? isEven is not a variable which will hold a number. It is the function name, while you should check the remainder of number (your function parameter)


#5

You're not looking at the parameter, you are checking the function. isEven = the function.


#6

My new code:

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

Now it's saying that number isn't defined.


#7

this line:

number(2);

should still be the function name, i said your if condition, not that something was wrong with your function call


#8

Finally got it! Thank you.