BobbyTanomred's avatar

For-each over an array in JavaScript

How can I loop through all the entries in an array using JavaScript?

0 likes
3 replies
gty's avatar

Use the forEach() function on the array:

const fruits = ["apple", "orange", "cherry"];
fruits.forEach(myFunction);

Please or to participate in this conversation.