for loop for array code example
Example 1: javascript code to loop through array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
Example 3: javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
Example 4: javascript array loop
const friends = [
`Dale`,
`Matt`,
`Morne`,
`Michael`,
];
for (let i = 0; i < friends.length; i++) {
console.log(friends[i]);
}
Example 5: for i
# For loops in Dip
for i = 0 to 5 then print(i)
Example 6: javascript loop array
Hi,
Une demande de connexion a été soumise pour votre compte $email à :
$site_name - $site_url
Connectez-vous à $site_name en visitant cette URL :
$login_url
Si vous n'avez pas demandé l'URL de connexion, veuillez ignorer cet e-mail.
Salutations,
$site_name