I'm confused about the JavaScript loops. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I'm confused about the JavaScript loops.

I need help. I'm trying to understand the JavaScript loops. But i can't. So i need someone who can teach me the loops.

13th Oct 2019, 4:19 PM
Muhammad Aman
Muhammad Aman - avatar
7 Answers
+ 3
this last example loops 5 times. First time: i=1 you write 1 onscreen. Then variable i is incremented by 1, so now i=2 Second loop: i=2 you write 2 onscreen. Then variable i is incremented by 1, so now i=3 etc etc Total output is: 1 2 3 4 5
13th Oct 2019, 5:46 PM
marjel101
marjel101 - avatar
+ 1
Could you explain what about the loops is confusing to you? And make sure you take the course on JavaScript.
13th Oct 2019, 4:23 PM
Zeke Williams
Zeke Williams - avatar
+ 1
I only see two kinds of loops here, and they are both for-loops. Are you confused about the syntax? for (initialize variables; condition that controls the loop; increment variables)
13th Oct 2019, 4:37 PM
Zeke Williams
Zeke Williams - avatar
+ 1
for (i=1; i<=5; i++) { document.write(i + "<br />"); } Here is another one
13th Oct 2019, 4:58 PM
Muhammad Aman
Muhammad Aman - avatar
0
Zeke Williams Here is my problem Here is the 3 kinds of loops I'm confused about them that how to write them document.write(i + "<br />"); } for (i=1, text=""; i<=12*4; i++) { text = i; document.write(i + "<br />"); } var i = 0; for (; i < 10; ) { document.write(i); i++;
13th Oct 2019, 4:28 PM
Muhammad Aman
Muhammad Aman - avatar
0
Zeke Williams can you explain them Please
13th Oct 2019, 4:57 PM
Muhammad Aman
Muhammad Aman - avatar