More on Control Flow issue


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Invalid or unexpected token


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


#2

The modulo equals zero which means there is no remainder when number is divided by 2. That makes it an even number. Switch false to true, and true to false in your branches.


#3

OK - but I still get a syntax error Invalid or unexpected token


#4

Thanks MTF,

Your solution helped me solve the problem. I was having trouble satisfying the condition inside the if statement that made it true. So here is the code that worked:

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

isEven(4);

I kept on putting: number % 2 = 0, which is incorrect syntax. In addition, I put number(4); at the bottom.


#5

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