Codewars: SyntaxError unexpected token '&&' in a If else statement

Trying to solve Opposites Attract kata with an if else statement to check if flower1 has even/odd pedals as well as flower2 using &&.

if ((flower1 % 2) == 1) && ((flower2 % 2) == 0){
return true;

Which gives a SyntaxError: unexpected token ‘&&’

>Solution :

if( ((flower1 % 2) == 1) && ((flower2 % 2) == 0) ){
return true;

}

You did it correctly just didn’t have enough brackets

Leave a Reply