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
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++;
}
+ 1
That seems to have fixed things Not printing even every line either! Thanks!