for javascript code example
Example 1: javascript for loop
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: javascript for
let str = "";
for (let i = 0; i < 9; i++) {
str = str + i;
}
console.log(str);
Example 3: javascript for loop
var i;
for (i = 0; i < 10 ; i++) {
}
Example 4: boucle for javascript
var i=0;
for (i=0;i<=6;i++){
document.write("Le nombre est : " + i);
document.write("<br />");
}
Example 5: for javascript
var texts = [
'a1',
'a2',
'a3',
];
for (var i = 0; i < texts.length; i++) {
console.log(texts[i]);
}
Example 6: javascipr for of
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}