- Arrays are ordered collections of elements. You can use loops to iterate through each element in an array.
const numbers = [1, 2, 3, 4, 5];
for (let i = 0; i < numbers.length; i++) {
console.log(numbers[i]);
}
-
Objects are collections of key-value pairs. You can loop through objects in arrays (called collections).
-
Loops allow you to perform operations on each element or property of an array or object, making them powerful tools for processing and manipulating data in your JavaScript programs.
- Connect your js file to your HTML file
- Open your code in the browser and open your console
- In the
js
file, complete the list of exercises.