2/9 - error ....returns false


#1

var isEven = function(number) {
if (number % 2 === 0) {
return true;
} else if (isNaN(number)) {
return false;
} else {
return "this number does not exist";
}
};
isEven()

My code above should work, but for some reason I am getting the error "
Oops, try again.
Your function returns true for 3!

What is wrong with it? where am i going wrong?


2/9 error
#2

Nevermind, I got it!


#3

what was the issue? I am getting the same error...


#4

in his case he had to do this

var isEven = function(number) {
                if (number % 2 === 0) {return true;} 
                else if (isNaN(number)) {return "this number does not exist";}
                else {return false;}
            };
console.log(isEven());
console.log(isEven(3));
console.log(isEven(4));

but he was making a check to see if there is a number passed or not. if we just do this

var isEven = function(number) {
                if (number % 2 === 0) {return true;} 
                else {return false;}
            };
console.log(isEven());
console.log(isEven(3));
console.log(isEven(4));

when there is no argument provided it will still return false;


#5

so why is it saying something about the number three?...


#6

Testing his code with all odd numbers was not returning false as expected but rather
'this number does not exist'

you can test out his code with some test samples in code academy labs below

var isEven = function(number) {
                if (number % 2 === 0) {return true;} 
                else if (isNaN(number)) {return false; }
                else {return "this number does not exist";}
            };
console.log(isEven());// will return false

//testing his code with any odd numbers 
//will give 'this number does not exist' 
//but we are expecting 'false'
console.log(isEven(3));
console.log(isEven(7));
console.log(isEven(11));

console.log(isEven(4));//true

#7

var isEven = function(number)
{
// Your code goes here!
if(number%2 === 0)
{
return "The number is Even Number";
}
else if(isNaN(number))
{
return "not a number";
}
else
{
return "The number is Odd Number";
}
};
isEven(55);

my code should work, but it is showing the below error..
Oops, try again.
Your function returns true for 3!....can any one please help me to solve it..


#8

perhaps you ought to be returning a boolean(true or false) value not a string


#9

You need to give the input parameter as a STRING for the function isEven.
so try isEven("TEST"); instead of isEven(55)