How do I get the even checks on the right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I get the even checks on the right?

Writing in JS, checking even if numbers from 1 to 6 are even. How do I get the even checks to be on the right while keeping the breaks. Is that possible? https://code.sololearn.com/WOWGF0Ck1Z9T/?ref=app https://code.sololearn.com/WOWGF0Ck1Z9T/?ref=app

1st Apr 2019, 10:48 PM
OrangeSword0999
OrangeSword0999 - avatar
2 Answers
+ 3
You were incrementing x before checking, which may've been causing yourself some confusion. The way the messages were printed could also be misleading you into thinking your code was wrong (?). Try this: while (x<6) { document.write(x) if (x % 2 == 0) { document.write(" : It's even") } document.write("<br>") x++; }
1st Apr 2019, 10:53 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
That seems to have fixed things Not printing even every line either! Thanks!
1st Apr 2019, 11:10 PM
OrangeSword0999
OrangeSword0999 - avatar