You can use the forEach() method to loop over an array and execute a function on each element of the array.
var pets = ['dog', 'cat', 'monkey'];
pets.forEach(function(element) {
console.log(element);
});
// expected output: "dog"
// expected output: "cat"
// expected output: "monkey"
For more information:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach