-
Notifications
You must be signed in to change notification settings - Fork 0
/
workers.js
47 lines (35 loc) · 1.05 KB
/
workers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// const workers = [
// {"name":"Jan","salary":500},
// {"name":"Liza","salary":1300},
// {"name":"Kate","salary":3000},
// {"name":"Jane","salary":900},
// {"name":"Tomas","salary":1700}
// ];
// const getRichWorkers = (workersArr) => {
// const richWorkers = [];
// for (i = 0; i < workersArr.length; i++) {
// const currentWorker = workersArr[i];
// if (currentWorker.salary > 1000) {
// richWorkers.push(currentWorker.name);
// }
// }
// return richWorkers;
// };
// console.log(getRichWorkers(workers));
const workers = [
{"name":"Jan","salary":500},
{"name":"Liza","salary":1300},
{"name":"Kate","salary":3000},
{"name":"Jane","salary":900},
{"name":"Tomas","salary":1700}
];
const getRichWorkers = (workersArr) => {
const richWorkers = [];
workersArr.forEach(currentWorker => {
if (currentWorker.salary > 1000) {
richWorkers.push(currentWorker.name);
}
})
return richWorkers;
};
console.log(getRichWorkers(workers));