loading
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
const fruits = ['pineapple', 'apple', 'banana', 'pear'];

console.log('forEach() example');
// improved looping
fruits.forEach((value, index, array) => {
    console.log('fruit at index', index, '=', value);
});

console.log('\nfor loop example');
// what you may already be used to
for (let i = 0; i < fruits.length; i++) {
    console.log('fruit at index', i, '=', fruits[i]);
}