for loop logic in javascript code example

Example 1: javascript loop

let array = ['Item 1', 'Item 2', 'Item 3'];

array.forEach(item => {
	console.log(item); // Logs each 'Item #'
});

Example 2: how to make a javascript for loop

var tops = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144];
for (let i = 0; i < tops.length; i++) {
  document.write(tops[i] + "tops");
}

Example 3: for loop js

let arr = [];
for(let i = 0; i <= 10; i++){
arr[i] = Math.round(Math.random() * 10);
}Result: [3, 1, 1, 2, 3, 9, 5, 6, 6, 8, 5]Or
let arr = [];
for(let i = 0; i <= 10; i++){
arr[i] = Math.trunc(Math.random() * 10);
} 
Result[7, 6, 0, 2, 4, 8, 7, 5, 5, 6, 5]