Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 ‘&&’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

}

You did it correctly just didn’t have enough brackets

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading