Skip to content

Commit 677f1b4

Browse files
committed
new: add foreach-method to JS TIL
1 parent 84fc8f1 commit 677f1b4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# How to Use the ForEach Method
2+
3+
---
4+
5+
In JavaScript, the `.forEach()` method lets you execute the function you provide once for each element in a given array.
6+
7+
```js
8+
const animals = ["Giraffe", "Orangutan", "Elephant"]
9+
10+
animals.forEach((animal) => console.log(animal))
11+
12+
// Giraffe
13+
// Orangutan
14+
// Elephant
15+
```
16+
17+
[link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/foreach)

0 commit comments

Comments
 (0)