Home > Software design >  Codewars: SyntaxError unexpected token '&&' in a If else statement
Codewars: SyntaxError unexpected token '&&' in a If else statement

Time:08-07

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 '&&'

CodePudding user response:

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

}

You did it correctly just didn't have enough brackets

  • Related