Skip to content

Commit 83b6f69

Browse files
committed
feat: Map utilizando o método FOR.
1 parent 057f96e commit 83b6f69

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

js-structure/map_method/map-for.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const users = [
2+
{
3+
id: 9,
4+
nome: "Iago Pedrosa",
5+
},
6+
{
7+
id: 16,
8+
nome: "Gabriel Azevedo",
9+
},
10+
{
11+
id: 14,
12+
nome: "Cleslley de Moura",
13+
},
14+
{
15+
id: 15,
16+
nome: "Maria Clara",
17+
},
18+
];
19+
20+
const lista = [];
21+
// lembrando que:
22+
// (incialização; condição; incremento/decremento)
23+
for (let i = 0; i < users.length; i++) {
24+
lista.push(users[i].nome);
25+
// lista recebe o array de (users[posição do index no array].item que você quer chamar)
26+
}
27+
28+
console.log(lista);

0 commit comments

Comments
 (0)