var text = "";
for (var i = 0; i < 5; i++) {
text += "The number is " + i + "
";
}
T he for statement creates a loop that is executed as long as a condition is true. The loop will continue to run as long as the condition is true. It will only stop when the condition becomes false. JavaScript supports different kinds of loops: for - loops through a block of code a number of times.