Loops tell the computer to run a function repeatedly. They are useful if you want to run the same code over and over again with a different input each time. To run the code a specific number of times, we use the for loop and tell the computer the numerical values in which we want the loop to run. We could also use the while loop and tell the computer the conditions in which we want the loop to run; so it won’t stop at a number but it will stop once the conditions are no longer met.
Link for image: https://blog.devgenius.io/the-anatomy-of-a-for-loop-in-javascript-9523c3da0d59