1/14 - Looks like your function returns false when number = 3


#1

keep getting the same error. I think it has something to do with my if number equation, but I'm not sure how to make it work. The hint didn't help

var isEven = function(number) {
if(number/2) {return true;}

else {return false}


#2

They want you to use the so-called remainder-operator
read
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

To check if you have an even-number
you should use
number%2 and do the comparison with =zero=
like
number%2 === 0

PS. do not forget the the closing-curly-bracket-}, with which you close the function-body

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html
http://javascript.crockford.com/survey.html


#3

Terima Kasih banyak atas ilmunya


#4

try adding "};" in the end of your code to see if it works that way. I had the same problem and I just looked to your exercise to realize what was wrong with mine and also figured out what may be wrong with yours.
Thanks.


#6

I am having the same issue and cannot figure out where my code is wrong.
var isEven = function(number) {
if ((isEven % 2) === 0) { return true; }
else { return false; }
};
isEven(8);

I always get "Looks like your function returns false when number = 2.
Can someone help please? Thanks


#7

isEven is then name of your function so [Function]%2 is kind of weird better use your parameter number here.


#8

Thank you. I need to go back and learn why using the function (which, in my mind should "resolve" to (number)) is different than using (number).
I really appreciate your answer!! Thanks!


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

I think you should add ((number % 2) === 0) instead of (number/2)


#11

thank you i was stuck on that one