how to use for as loop in js 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 loop

let my_capacity = 15;
for (let my_var = 0; my_var < my_capacity; my_var++)
{
  console.log(my_var)
}

Example 3: for in js loop

Example:
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"


Syntax:
for (variable in object)
  statement