Skip to content

Commit dd8b7d4

Browse files
authored
Merge branch 'js-tasks-ru:master' into master
2 parents d6dc666 + 3851a3d commit dd8b7d4

File tree

3 files changed

+332
-0
lines changed

3 files changed

+332
-0
lines changed

3-module/4-task/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Функция showSalary(users, age)
2+
3+
Создайте функцию `showSalary`, которая принимает массив пользователей `users` и максимальный возраст `age` и возвращает строку с именами и зарплатами пользователей, у которых **возраст меньше или равен параметру `age`**.
4+
5+
```js
6+
// users - массив пользователей
7+
// age - максимальный возраст пользователей (любое число)
8+
let result = showSalary(users, age);
9+
```
10+
11+
`users` - это массив пользователей, где каждый пользователь представлен объектом, содержащим следующие обязательные поля:
12+
13+
```js
14+
// Объект одного пользователя
15+
let user1 = {
16+
"balance": "$1,825.65",
17+
"picture": "https://placehold.it/32x32",
18+
"age": 21,
19+
"name": "Golden Branch",
20+
"gender": "male",
21+
"greeting": "Hello, Golden Branch! You have 7 unread messages.",
22+
"favouriteFruit": "banana"
23+
};
24+
25+
// Массив пользователей
26+
let users = [user1, <...и другие пользователи>]
27+
```
28+
29+
Функция `showSalary` должна возвращать **строку из имён и баланса подходящих пользователей**, в формате:
30+
31+
```text
32+
'Golden Branch, $1,825.65
33+
Duncan Randall, $1,490.15'
34+
```
35+
36+
**(!!!)** Обратите внимание, что каждый пользователь **находится на новой строке**. Это сделано специально и должно быть учтено в решении.
37+
38+
**(!!!)** При этом нужно учесть, что после последней строки **не нужно добавлять перевод строки**. При проверке решения это условие также учитывается.
39+
40+
Почитать про то, как реализовать перевод строки можно вот тут [Спецсимволы в строках](https://learn.javascript.ru/string#spetssimvoly)

3-module/4-task/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function showSalary(users, age) {
2+
// ваш код...
3+
}

3-module/4-task/task.test.js

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
/* eslint-disable */
2+
const data = [
3+
{
4+
'balance': '$1,825.65',
5+
'picture': 'https://placehold.it/32x32',
6+
'age': 21,
7+
'name': 'Golden Branch',
8+
'gender': 'male',
9+
'greeting': 'Hello, Golden Branch! You have 7 unread messages.',
10+
'favouriteFruit': 'banana'
11+
},
12+
{
13+
'index': 1,
14+
'guid': '53c90e0c-b8b2-494b-8508-7d5870af0351',
15+
'isActive': true,
16+
'balance': '$1,490.15',
17+
'picture': 'https://placehold.it/32x32',
18+
'age': 26,
19+
'eyeColor': 'green',
20+
'name': 'Duncan Randall',
21+
'gender': 'male',
22+
'company': 'MATRIXITY',
23+
'email': '[email protected]',
24+
'phone': '+1 (861) 585-3156',
25+
'address': '860 Lamont Court, Bowden, South Carolina, 3719',
26+
'about': 'Exercitation magna aliquip veniam exercitation esse est cillum non in. Dolor magna nostrud irure nulla elit anim fugiat et eiusmod. Elit reprehenderit mollit officia eiusmod consectetur id. Anim sunt deserunt aliqua eu sint mollit Lorem quis officia in aliquip dolore. Adipisicing ut ut aliquip est occaecat magna deserunt ad magna labore culpa velit sunt commodo. Nulla laboris irure amet voluptate sit excepteur mollit nostrud. Ullamco reprehenderit proident anim laborum dolore deserunt sunt nostrud deserunt in enim.\r\n',
27+
'registered': '2015-03-09T02:11:47 -03:00',
28+
'latitude': -36.819023,
29+
'longitude': -6.01344,
30+
'tags': [
31+
'aliquip',
32+
'esse',
33+
'nisi',
34+
'commodo',
35+
'ad',
36+
'velit',
37+
'qui'
38+
],
39+
'friends': [
40+
{
41+
'id': 0,
42+
'name': 'Townsend Lindsey'
43+
},
44+
{
45+
'id': 1,
46+
'name': 'Georgette Blackwell'
47+
},
48+
{
49+
'id': 2,
50+
'name': 'Knowles Cervantes'
51+
}
52+
],
53+
'greeting': 'Hello, Duncan Randall! You have 2 unread messages.',
54+
'favouriteFruit': 'banana'
55+
},
56+
{
57+
'index': 2,
58+
'guid': '2483e252-b0d2-4a26-98e6-513531b320b7',
59+
'isActive': true,
60+
'balance': '$1,664.27',
61+
'picture': 'https://placehold.it/32x32',
62+
'age': 37,
63+
'eyeColor': 'brown',
64+
'name': 'Glass Ray',
65+
'gender': 'male',
66+
'company': 'ANIVET',
67+
'email': '[email protected]',
68+
'phone': '+1 (953) 592-3001',
69+
'address': '864 Driggs Avenue, Newkirk, New Jersey, 4485',
70+
'about': 'Laboris ex mollit ut excepteur qui adipisicing magna eu anim nulla anim sint sunt officia. Commodo nisi cupidatat aliquip laboris consectetur et commodo veniam nisi sunt nostrud culpa ipsum laborum. Tempor aliquip sint amet culpa.\r\n',
71+
'registered': '2016-07-16T09:20:34 -03:00',
72+
'latitude': 76.633104,
73+
'longitude': 1.779366,
74+
'tags': [
75+
'voluptate',
76+
'excepteur',
77+
'fugiat',
78+
'aute',
79+
'dolore',
80+
'aliqua',
81+
'minim'
82+
],
83+
'friends': [
84+
{
85+
'id': 0,
86+
'name': 'Simmons Grimes'
87+
},
88+
{
89+
'id': 1,
90+
'name': 'Chandra Vasquez'
91+
},
92+
{
93+
'id': 2,
94+
'name': 'Jimenez Hayes'
95+
}
96+
],
97+
'greeting': 'Hello, Glass Ray! You have 8 unread messages.',
98+
'favouriteFruit': 'strawberry'
99+
},
100+
{
101+
'index': 3,
102+
'guid': '51855992-a0e7-4821-8178-92bcd13a1f0c',
103+
'isActive': true,
104+
'balance': '$1,072.95',
105+
'picture': 'https://placehold.it/32x32',
106+
'age': 40,
107+
'eyeColor': 'brown',
108+
'name': 'Helga Nixon',
109+
'gender': 'female',
110+
'company': 'KENEGY',
111+
'email': '[email protected]',
112+
'phone': '+1 (832) 595-2918',
113+
'address': '658 Scholes Street, Day, Illinois, 3262',
114+
'about': 'Labore id aute id voluptate do sint ex veniam dolor do non velit. Proident consectetur ipsum laboris ea aliquip ea. Incididunt ut labore incididunt sunt ipsum ipsum Lorem quis proident nulla sit cillum duis. Veniam labore aliqua in elit aute. Pariatur deserunt dolore fugiat mollit. Excepteur ea nostrud aliquip officia fugiat. Occaecat elit elit consectetur et commodo aliqua reprehenderit eu nulla excepteur.\r\n',
115+
'registered': '2015-09-27T01:16:15 -03:00',
116+
'latitude': 63.00501,
117+
'longitude': -27.098594,
118+
'tags': [
119+
'consequat',
120+
'reprehenderit',
121+
'quis',
122+
'esse',
123+
'sint',
124+
'dolore',
125+
'amet'
126+
],
127+
'friends': [
128+
{
129+
'id': 0,
130+
'name': 'Andrews Sharp'
131+
},
132+
{
133+
'id': 1,
134+
'name': 'Leona Jacobson'
135+
},
136+
{
137+
'id': 2,
138+
'name': 'Marie Parker'
139+
}
140+
],
141+
'greeting': 'Hello, Helga Nixon! You have 3 unread messages.',
142+
'favouriteFruit': 'banana'
143+
},
144+
{
145+
'index': 4,
146+
'guid': '83405931-c746-4ed6-a05f-10b79b018af2',
147+
'isActive': false,
148+
'balance': '$3,422.96',
149+
'picture': 'https://placehold.it/32x32',
150+
'age': 45,
151+
'eyeColor': 'blue',
152+
'name': 'Felicia Browning',
153+
'gender': 'female',
154+
'company': 'TRASOLA',
155+
'email': '[email protected]',
156+
'phone': '+1 (947) 523-3902',
157+
'address': '561 Rost Place, Tryon, District Of Columbia, 1276',
158+
'about': 'Elit commodo adipisicing duis voluptate ut ad. Occaecat consectetur amet do qui cupidatat anim aliqua laborum culpa quis id officia. Non aute irure reprehenderit officia id aliquip adipisicing non aliqua voluptate fugiat nulla dolor cillum. Commodo cillum id irure magna ut commodo aliqua in velit tempor pariatur voluptate nulla. Laborum consectetur magna mollit fugiat ad fugiat velit adipisicing qui et qui amet. Do esse enim ullamco excepteur eiusmod ipsum deserunt id consectetur deserunt anim amet.\r\n',
159+
'registered': '2014-11-12T03:57:54 -03:00',
160+
'latitude': -19.354794,
161+
'longitude': 125.464668,
162+
'tags': [
163+
'tempor',
164+
'sunt',
165+
'consectetur',
166+
'est',
167+
'minim',
168+
'enim',
169+
'cillum'
170+
],
171+
'friends': [
172+
{
173+
'id': 0,
174+
'name': 'Hudson Hartman'
175+
},
176+
{
177+
'id': 1,
178+
'name': 'Marshall Hebert'
179+
},
180+
{
181+
'id': 2,
182+
'name': 'Rosario Benson'
183+
}
184+
],
185+
'greeting': 'Hello, Felicia Browning! You have 4 unread messages.',
186+
'favouriteFruit': 'banana'
187+
},
188+
{
189+
'index': 5,
190+
'guid': 'd4f7c1c1-a902-431c-95ce-034f74cae5c7',
191+
'isActive': false,
192+
'balance': '$2,560.80',
193+
'picture': 'https://placehold.it/32x32',
194+
'age': 39,
195+
'eyeColor': 'brown',
196+
'name': 'Parrish Jordan',
197+
'gender': 'male',
198+
'company': 'PARCOE',
199+
'email': '[email protected]',
200+
'phone': '+1 (975) 582-2005',
201+
'address': '178 Franklin Street, Fredericktown, Missouri, 6785',
202+
'about': 'Officia ex tempor est eiusmod aliquip Lorem. Veniam mollit anim pariatur consequat. Qui exercitation deserunt esse est.\r\n',
203+
'registered': '2016-04-23T09:49:37 -03:00',
204+
'latitude': 56.387518,
205+
'longitude': -32.3259,
206+
'tags': [
207+
'pariatur',
208+
'incididunt',
209+
'labore',
210+
'dolore',
211+
'mollit',
212+
'mollit',
213+
'exercitation'
214+
],
215+
'friends': [
216+
{
217+
'id': 0,
218+
'name': 'Rosa Manning'
219+
},
220+
{
221+
'id': 1,
222+
'name': 'Fernandez Leach'
223+
},
224+
{
225+
'id': 2,
226+
'name': 'Crawford Dejesus'
227+
}
228+
],
229+
'greeting': 'Hello, Parrish Jordan! You have 3 unread messages.',
230+
'favouriteFruit': 'banana'
231+
},
232+
{
233+
'index': 6,
234+
'guid': '7f120395-5c8b-4fdc-9dd6-6892af61e28b',
235+
'isActive': true,
236+
'balance': '$2,461.96',
237+
'picture': 'https://placehold.it/32x32',
238+
'age': 55,
239+
'eyeColor': 'green',
240+
'name': 'Adela Wooten',
241+
'gender': 'female',
242+
'company': 'ANOCHA',
243+
'email': '[email protected]',
244+
'phone': '+1 (991) 588-2830',
245+
'address': '706 Will Place, Needmore, Montana, 9130',
246+
'about': 'Fugiat ea irure nisi aute Lorem ad exercitation nostrud. Laborum anim ullamco deserunt non minim sunt mollit duis labore ad ex veniam mollit. Dolor elit culpa esse fugiat ea non amet minim consequat. Lorem esse elit aute dolor enim adipisicing commodo. Esse id enim proident incididunt non proident cillum officia elit reprehenderit consequat qui et ut.\r\n',
247+
'registered': '2017-04-22T12:16:38 -03:00',
248+
'latitude': 58.71205,
249+
'longitude': 127.576842,
250+
'tags': [
251+
'esse',
252+
'reprehenderit',
253+
'voluptate',
254+
'fugiat',
255+
'pariatur',
256+
'nisi',
257+
'mollit'
258+
],
259+
'friends': [
260+
{
261+
'id': 0,
262+
'name': 'Kendra Mcgowan'
263+
},
264+
{
265+
'id': 1,
266+
'name': 'Meghan Ramos'
267+
},
268+
{
269+
'id': 2,
270+
'name': 'Johns Rich'
271+
}
272+
],
273+
'greeting': 'Hello, Adela Wooten! You have 7 unread messages.',
274+
'favouriteFruit': 'strawberry'
275+
}
276+
];
277+
/* eslint-enable */
278+
279+
describe('3-module-4-task', () => {
280+
it('для пользователей до 30 лет должна вывести строку с зарплатами', () => {
281+
expect(showSalary(data, 30)).toEqual('Golden Branch, $1,825.65\nDuncan Randall, $1,490.15');
282+
});
283+
284+
it('для пользователей до 40 лет должна вывести строку с зарплатами', () => {
285+
/* eslint-disable */
286+
expect(showSalary(data, 40)).toEqual('Golden Branch, $1,825.65\nDuncan Randall, $1,490.15\nGlass Ray, $1,664.27\nHelga Nixon, $1,072.95\nParrish Jordan, $2,560.80');
287+
/* eslint-enable */
288+
});
289+
});

0 commit comments

Comments
 (0)