1/14 Help! My code does not work


#1

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


#2

Hi, I can give you what worked for me. I'm not sure what the condition in your "else if" should work like. I would just remove it or else you should rewrite it.

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


#3

Yep that's what I got!!

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


#4

This what worked for me:

var isEven = function(number) {
// Your code goes here!
var cal = number % 2;

if ( cal === 0) {
return true;
}
else {
return false;
}
};

isEven(4);


#5

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

worked for me


#6

Hate to say this, but this really should not work. The whole function is missing. isEven is undefined. you try the modulo operator on something which is expected to be a function name. No really this should not work pls have a look at the instructions and the other examples.


#7

Does "var isEven = function(number) " define isEven?


#8
var isEven = function(number) {}

yes this would.


#9

THANK YOU I SAT HERE FOR HALF AN HOU TRYING TO SOLVE THIS i feel ashamed that i can't do it myself but oh well!!! :grin: :stuck_out_tongue_closed_eyes:


#10

Here's a simple solution that makes the function work:

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

isEven(2);

#11

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


#12

@unimog Could you give some words of explanaition why this code works and what makes it different from what is already posted and from what the author posted?


#13

i just poped in and gave a reply..
code's d same. dnt knw it was down der.