JavaScript supports different kinds of loops as follows:
•for - loops through a block of code a number of times
•for/in - loops through the properties of an object or the elements in an array
•while - loops through a block of code while a specified condition is true
•do/while - also loops through a block of code while a specified condition is true
The for loop has the following syntax:
for (var i = 0; i < 5; i++) {
text += "The number is " + i;
}
There are other loop constructs—consult https://www.w3schools.com/js/