A loop is a programming construct that allows you to repeat a specific set of code multiple times. There are several different types of loops in JavaScript, but they essentially do the same thing: Repeat an action a certain amount of times. Here are some examples:
for (var i = 0; i < array.length; i++) {
console.log(array[i]);
}
array.forEach(function(element) {
console.log(element);
});
array.map(function(element) {
console.log(element);
});
array.filter(function(element) {
return element === 3;
});
array.some(function(element) {
return element === 3;
});
array.every(function(element) {
return element === 3;
});
array.reduce(function(accumulator, element) {
return accumulator + element;
}, 0);
Feel free to reach out if you have any questions or comments.