<script> index = 0; array = [ 1, 2, 3, 4, 5, 6 ]; array.forEach(myFunction); function myFunction(item, index) { console.log(item); }</script>
const array = ["one", "two", "three"] array.forEach(function (item, index) { console.log(item, index); });
var colors = ["red","blue","green"]; for (var i = 0; i < colors.length; i++) { console.log(colors[i]); }
var myStringArray = ["hey","World"]; var arrayLength = myStringArray.length; for (var i = 0; i < arrayLength; i++) { console.log(myStringArray[i]); //Do something }
/* ES6 */ const cities = ["Chicago", "New York", "Los Angeles"]; cities.map(city => { console.log(city) })
const array = ["hello", "world"]; for (item of array) { //DO THIS }
let numbers = [1,2,3,4,5]; let numbersLength = numbers.length; for ( let i = 0; i < numbersLength; i++) { console.log (numbers[i]); }