Skip to content

Commit a525c48

Browse files
afteruniversity/feat/map-method
feat: Map method with .map()
2 parents 83b6f69 + 71e336c commit a525c48

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

js-structure/map_method/map-map.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const array = [
2+
{
3+
id: 1,
4+
nome: "João",
5+
idade: 25,
6+
},
7+
{
8+
id: 2,
9+
nome: "Maria",
10+
idade: 30,
11+
},
12+
{
13+
id: 3,
14+
nome: "Carlos",
15+
idade: 28,
16+
},
17+
];
18+
19+
array.map((item, idx) => {
20+
console.log(item.nome, item.idade, idx);
21+
// item.'' retorna o item de dentro do objeto que você deseja.
22+
// idx retorna a posição do index.
23+
});

0 commit comments

Comments
 (0)