for (initialization; condition; increment) {
// Code to be executed
}
Here’s an example of a simple for
loop that prints the numbers from 1 to 10:
for (let i = 1; i <= 10; i++) {
console.log(i);
}
Example that loops through an array and prints each element:
let fruits = ["apple", "banana", "cherry"];
for (let i = 0; i < fruits.length; i++) {
console.log(fruits[i]);
}