I have been learning loops for a while now and its gets trickier every now and then lol . I would love to know some real world examples for using loops.
I am not sure what you are hoping to see, but have a peruse through the freeCodeCamp GitHub repo: https://github.com/freeCodeCamp/freeCodeCamp/blob/master/curriculum/test/test-challenges.js#L180
You will struggle to find them, as we mostly make use of higher-order functions (which make use of
Programmatically? Well, using loops we can find the result of any geometric or arithmetic series (unless it’s infinite). If you’re talking about a real-world software application, then how about ATM machines? You type in for a specific amount and until that specific amount is reached the machine continues dispensing you notes.
A real life example of a loop could be your music playlist. While you have a song that’s available to be played, it will keep going through your song list and stop when there is no more music that can be listened to.
Thank you @Sky020 for this GigHub repo, I would check it out.
hahaha @selectiveduplicate the ATM machine is a great one, never have I thought about it that way. Thank you.
wow @hjanday hahaha thank you. I am beginning to appreciate the use of loops more and more now.
We use loops (or methods that have loops under the covers) all the time. We are very often dealing with a list of things and we need to repeat the same behavior for each one. A quick search showed that we have 26 basic
for loops in a relatively small project.
Instead of inputting/adding a value manually we use the loop to return that value as many times as possible so you don’t have to write a particular text manually over 50 times or more. An example can be the list you of songs you have on your music app. Each time a new music is added we output a new line of div or paragraph. I Hope this helps
An example from my world is that I have made a powershell script that fetches users from Microsoft Active Directory into a list, loops through that list and, based on usernames adds them to different security groups for mapping a home directory