1const array = [1, 2, 3, 4];
2
3
4const map = array.map((x, index) => {
5 console.log(index);
6 return x + index;
7});
8
9console.log(map);
1const array1 = [1, 4, 9, 16];
2
3// pass a function to map
4const map1 = array1.map(x => x * 2);
5
6console.log(map1);
7// expected output: Array [2, 8, 18, 32]