How to loop over an array in JavaScript

1 Answer

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

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


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

 



answered Nov 28, 2020 by avibootz

Related questions

1 answer 174 views
2 answers 212 views
2 answers 238 views
2 answers 159 views
159 views asked Aug 27, 2022 by avibootz
1 answer 140 views
1 answer 151 views
151 views asked Oct 10, 2020 by avibootz
...