Skip to content

Commit fdbc692

Browse files
feat: added forEach array method
1 parent 36d8ef5 commit fdbc692

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Array Methods/forEach.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// forEach
2+
// does not return new array
3+
4+
const people = [
5+
{ name: 'bob', age: 20, position: 'developer' },
6+
{ name: 'peter', age: 25, position: 'designer' },
7+
{ name: 'susy', age: 30, position: 'the boss' },
8+
];
9+
10+
function showPerson(person) {
11+
console.log(person.position.toUpperCase());
12+
}
13+
14+
// people.forEach(showPerson);
15+
16+
people.forEach(function (item) {
17+
console.log(item.position.toUpperCase());
18+
});

0 commit comments

Comments
 (0)