Introduction
The for loop is the most common loop used in JavaScript programming.
The for loop consists of 3 parts:
1. The initialization stage
2. the test stage
3. the iteration stage.
In the initialization stage, we set a counter variable with a numerical value to indicate where the loop should start from.
In the test stage, a condition for the counter is specified so that the loop knows when to stop.
In the iteration stage, a statement is written so that the loop knows by how much to decrease or increase the counter value at each step.
A developer may implement a loop that writes the numbers 1 to 10 on the web page like this: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/loops/ex1.js?actionable=true In the above example, the counter variable is declared in the first line, then initialized like so counter = 0.
The test statement is counter
$(document).ready(function(){
XT1
});
</script>
Live demo
<div id="minidivpage" class="example-live"><div id="resultdiv"></div></div>
$(document).ready(function() {
XT1
});
</script>