1. If / else


#1

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

//what is wrong with this I really don't understand??


#2

if the remainder equals zero, you don't check if number % 2 equals (==) 0


#3

:smiley: that was the problem such a silly mistake, though thanks a lot for all your time...


#4

yes, here is the catch, for even numbers the remainder is zero, make sense? and for odd numbers the remainder is 1, also make sense? okay, if you then know that zero is considered false, and one is considered true, you could also do this:

if(number % 2 ) {
      return false;
  }
  else { 
      return true;
  }

if will run for odd numbers, else for false numbers, might this might be a bit more difficult to comprehend.


#5

I figured it out Thanks a lot for your time though... Thanks a lot


#6

i know you did figure it out, just some additional insight


#7

Ok.. Thanks for all the support that you have given me till now...


#8