JavaScript Loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

JavaScript Loops

I just finished the "Loops and conditionals" section in the JavaScript and I am having a hard time trying to think of ways to use Loops. All the loops I create now are just counting up or down. Frankly, that is quite boring. I was just wandering if anyone could give me examples that use loops and that are interesting and just don't count up and down :). Thank you for response that you gave me.

5th Apr 2018, 6:18 PM
Bradley
2 Answers
+ 2
loops allow to repeat certain tasks or functions. depending on what is inside the loop, this can be interesting. also nesting loops in loops. in general loops are often used because they are useful.
5th Apr 2018, 6:35 PM
wenz
wenz - avatar
+ 1
Hi Bradley Loops are used a lot to iterate data structures. eg -Sifting through an array of names and addresses to find all people called mike -checking through the list of coordinates for game characters to see if they have been hit -sorting a list of names in to alphabetical order. -walking through a visibility tree in a 3d game to see what should be displayed -working out the average age of a list of people etc etc etc Hope this helps to relate to the real and virtual world have a look on the Sololearn course on data structures to find out more.
5th Apr 2018, 6:39 PM
Mike Choy
Mike Choy - avatar