Answers for "iteration in javascript example"

1

loop an array in javascript

let array = ["loop", "this", "array"]; // input array variable
for (let i = 0; i < array.length; i++) { // iteration over input
	console.log(array[i]); // logs the elements from the current input
}
Posted by: Guest on May-18-2020
2

Iterate with JavaScript For Loops

var myArray = [];
for (var i = 1; i <= 5; i++){
    myArray.push(i);
} 
console.log(myArray) // console output [ 1, 2, 3, 4, 5 ]
Posted by: Guest on December-21-2020
0

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]
Posted by: Guest on August-07-2020

Code answers related to "iteration in javascript example"

Code answers related to "Javascript"

Browse Popular Code Answers by Language