JavaScript Arrays
<!DOCTYPE html> <html> <body> <h2>forEach and the for...of loop</h2> <script> const cart = ["pen", "notebook", "eraser"]; // forEach gives you each element and its index cart.forEach((item, index) => { console.log(`${index + 1}. ${item}`); }); // 1. pen // 2. notebook // 3. eraser // for...of is a clean way to loop when you only need the values for (const item of cart) { console.log(item.toUpperCase()); } </script> </body> </html>