let panier = ['fraise', 'banane', 'poire'];
for (const fruit in panier) {
console.log(panier[fruit]);
}
for (let step = 0; step < 5; step++) {
// Runs 5 times, with values of step 0 through 4.
console.log(step);
}
0
1
2
3
4
const object = { a: 1, b: 2, c: 3 };
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
// expected output:
// "a: 1"
// "b: 2"
// "c: 3"
//for ... in statement
const object = { a: 1, b: 2, c: 3 };
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
// expected output:
// "a: 1"
// "b: 2"
// "c: 3"
for (let i = start; i < end; i++) {
}
var colors=["red","blue","green"];
for(let col of colors){
console.log(col);
}
// red
// blue
// green
let items = ['beef', 'cabbage', 'javascript']; // Defines a list of items
for (let item of items) { // Defines for loop with a variable of 'item'
console.log(item); // Prints the item that is found
}
const user ={
name:'Shirshak',
age:25,
subscibers:200,
money:'lolno'
}
for(let x in user){
console.log(user[x]) //name,age,subscriber and money(only get key not value)
}
for (variable in object) {
statement
}
for (variable in object) {...
}
for (variable in object) {
statement
}
for (variable in object) {
statement
}
for (variable in object) {
statement
}