How to loop through arrays in javascript?
JavaScript provides multiple ways to iterate over arrays, including for-loops and forEach.
Example:
let numbers = [1, 2, 3, 4, 5];
for(let i = 0; i < numbers.length; i++) {
console.log(numbers[i]);
}
Solution:
Using the forEach method:
numbers.forEach(function(number) {
console.log(number);
});