Loops offer a quick and easy way to do something repeatedly
Javascript offers many different ways to loop, click here for more information
var fruits=[“Banana”,”Apple”,”Pear”];
fruits.forEach(function(element,index){
console.log(element,index);
});
click here for more information about the forEach() loop
var fruits=[“Banana”,”Apple”,”Pear”];
$.each(fruits, function(index, element){
console.log(index, element);
});
click here for more information about the jQuery’s $.each() loop