Even number? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Even number?

Problem below, cannot figure out what my mistake is. Any help appreciated (It's saying my == is incorrect) . function main(){ var numGuests = (parseInt(readLine (), 10) if (numGuests % == 0) (console.log("Right")); else(console.log("Wrong")); https://www.sololearn.com/learning/1024/1137/1398/2

20th Jan 2021, 2:10 AM
tristach605
tristach605 - avatar
2 Answers
+ 6
You need to ‘divide’ (%) numGuests by 2 before you perform the comparison operation (==). Your if statement should be: if(numGuests % 2 == 0)
20th Jan 2021, 2:20 AM
Elizabeth Kelly
Elizabeth Kelly - avatar
+ 1
Thanks so much, Elizabeth Kelly. I really appreciate your help:).
20th Jan 2021, 2:22 AM
tristach605
tristach605 - avatar