I was trying to print a number 1 to 3 and when it becomes multiple by 3, it will create a <br>
and then continue until it meets the number 185.
I try this code but it gives me a wrong answer:
for (a = 1; a <= 185; a++) {
document.write(" ", a);
if (a % 3) {
document.write("<br>");
}
}
But it gives me this answer:
1<br>
2<br>
3 4<br>
5<br>
6 7
Instead of:
1 2 3<br>
4 5 6<br>
7 8 9