Skip to content

Commit

Permalink
Added task Трансформировать в массив имён
Browse files Browse the repository at this point in the history
  • Loading branch information
jsru-1 committed Sep 30, 2024
1 parent 406ff5f commit 413f346
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 3-module/1-task/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Трансформировать в массив имён

У вас есть массив объектов `user`, и в каждом из них есть `user.name`. Напишите функцию `namify`, которая преобразует их в массив имён.

Например:

```js
let vasya = { name: 'Вася', age: 25 };
let petya = { name: 'Петя', age: 30 };
let masha = { name: 'Маша', age: 28 };

let users = [ vasya, petya, masha ];

function namify(users) {
// ваш код
}

let names = namify(users); // ['Вася', 'Петя', 'Маша']
```
3 changes: 3 additions & 0 deletions 3-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function namify(users) {
// ваш код...
}
12 changes: 12 additions & 0 deletions 3-module/1-task/task.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('3-module-1-task', () => {
it('должна преобразовать users в массив имён', () => {
let vasya = { name: 'Вася', age: 25 };
let petya = { name: 'Петя', age: 30 };
let masha = { name: 'Маша', age: 28 };

let users = [vasya, petya, masha];
let names = ['Вася', 'Петя', 'Маша'];

expect(namify(users)).toEqual(names);
});
});

0 comments on commit 413f346

Please sign in to comment.