Skip to content

Files

Latest commit

677f1b4 · Dec 22, 2022

History

History
17 lines (11 loc) · 414 Bytes

foreach-method.md

File metadata and controls

17 lines (11 loc) · 414 Bytes

How to Use the ForEach Method


In JavaScript, the .forEach() method lets you execute the function you provide once for each element in a given array.

const animals = ["Giraffe", "Orangutan", "Elephant"]

animals.forEach((animal) => console.log(animal))

// Giraffe
// Orangutan
// Elephant

link