0

Iterating over Array in JavaScript with index and element

JavaScript
const a = ['a', 'b', 'c'];
const entries = a.entries();


for (const [index, element] of entries) {
  console.log(index, element); // 0,"a"  
                               // 1,"b"
                               // 2,"c"
}
RUN
add comment
Suggest a different solution or add another example