Error: "...function returns false when number = 3. "


#1

Write an if / else statement inside the isEven function.
It should return true; if the number it receives is evenly divisible by 2. Otherwise (else), it should return false;.


var isEven = function(number) {
// Your code goes here!
var number = prompt ("Enter a number");

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


could someone please help, can't see it, thank you.


#2

You are returning the string for true and false rather than just true and false.


#3

Here I was going through a similar mistake as you are / were going. (adding an extra var inside the function)
Remove the variable inside the function and just write RETURN TRUE and RETURN FALSE. That will do the trick.


#4

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