Why do we use loops?
We use loops in JavaScript to perform an action multiple times. Loops allow us to do this without having a crazy amount of unnecessary code. We add a condition to the loop so that way it will run as long as the condition is true. As soon as the condition is false, the loop will stop running. This allows for certain tasks like mathematical ones in which we add increments to a total to be relatively easy to code for.
Leave a Reply
You must be logged in to post a comment.