Підходи до написання коду
const array = [1, 2, 3, 4, 5];
function myFunc(arr) {
const numberElements = arr.length;
for (let i = 0; i < numberElements; i += 1) {
console.log(`Element with index ${i} is ${arr[i]}`);
}
}
myFunc(array);const array = [1, 2, 3, 4, 5];
array.forEach((el, i) => {
console.log(`Element with index ${i} is ${el}`);
});Last updated