Skip to content

Commit a994ba4

Browse files
committed
[EX-13.4/st-compl] transforming-obj-users
Transforming obj/users, getting "new" obj's/view by "map()" method. Worth noting: - the possibilities of the "map()" method. FS-dev: B-3 / JS basic
1 parent c762626 commit a994ba4

File tree

1 file changed

+32
-0
lines changed
  • full-stack-dev/3-js-basic/13-objects/13-4-ex-transforming-obj-users

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Нужно преобразовать искомый массив с объектами/пользователями до следующего вида:
2+
// [{ fullName: 'Вася Пупкин', skillNum: 2 }, ... ]
3+
// Рекомендуется отработать через метод map().
4+
5+
const users = [
6+
{
7+
name: 'Вася',
8+
surname: 'Пупкин',
9+
age: 30,
10+
skills: ['Разработка', 'DevOps'],
11+
},
12+
{
13+
name: 'Катя',
14+
surname: 'Белова',
15+
age: 18,
16+
skills: ['Дизайн'],
17+
},
18+
];
19+
20+
const newLookUsers = users.map((user) => ({
21+
fullName: `${user.name} ${user.surname}`,
22+
skillNum: user.skills.length,
23+
}));
24+
25+
console.log(newLookUsers);
26+
27+
/*
28+
[
29+
{ fullName: 'Вася Пупкин', skillNum: 2 },
30+
{ fullName: 'Катя Белова', skillNum: 1 }
31+
]
32+
*/

0 commit comments

Comments
 (0)