How to print array elements with indexes in JavaScript

1 Answer

0 votes
let arr = ['javascript', 'c++', 'php', 'java'];

arr.forEach(function(item, index, array) {
  	console.log(item, index)
})


    
    
/*
run:
    
"javascript", 0
"c++", 1
"php", 2
"java", 3
    
*/

 



answered Nov 28, 2020 by avibootz

Related questions

2 answers 304 views
1 answer 214 views
1 answer 251 views
1 answer 253 views
...