JavaScript loops | Sololearn: Learn to code for FREE!


JavaScript loops

Plz any one explain me by example that using loops can helps really make easy . And the use of loops in many real life projects.

5/3/2021 5:57:25 PM

Aurosish dev

3 Answers

New Answer


Loop is very useful and you'll understand them only if you keep using them. There's a For loop For in loop For of loop For each loop While loop All they do is to iterate through some sequence based on a define condition. A real world use while loop is to calculate the factorial of a number N let N = 5; let res = 1; let counter = N; while (counter) { res *= counter; counter--; } ; console.log(res)


In programming not only javascript, loops are used to repeat a block of code.


Thanks everyone for answering .