#1. if/else


#1

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

It is supposed to return true when the number is evenly divisible by 2 which it is`
I get the error message saying that function returns false when divided by 3
what am I doing wrong?

`


#2

Please read here how a function should be declared and than look at your code :slight_smile:

Functions


#3

your code is right except the first line. it first line should be :
var isEven = function(number) {


#4

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

isEven(4);

Looks like your function returns false when number = 3. Check whether your code inside the if/else statement correctly returns true if the number it receives is odd.

Please help, what did I miss?


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.