-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduce.js
More file actions
76 lines (71 loc) · 1.41 KB
/
reduce.js
File metadata and controls
76 lines (71 loc) · 1.41 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// const numbers = [1, 2, 3, 5];
// const rta = numbers.reduce((count, value) => {
// return count + value;
// }, 0);
// console.log(numbers, rta);
const tasks = [
{
id: 1343,
title: 'Fix issue 423',
duration: 60,
completed: true,
},
{
id: 2454,
title: 'Make new chart for dashboard',
duration: 120,
completed: false,
},
{
id: 32323,
title: 'Show validations in form',
duration: 180,
completed: true,
},
{
id: 45434,
title: 'Make new endpoint for login',
duration: 240,
completed: true,
},
];
const rta = tasks
.map(task => {
return {
...task,
durationInHours: task.duration / 60
};
})
.filter(task => task.completed)
.reduce((count, task) => {
// console.log(count, task);
return count + task.durationInHours;
}, 0);
// const obj = tasks.find(item => item.id === 32323);
const position = tasks.indexOf(item => item.id === 32323);
// obj.title = 'jskhfjksah';
console.log(position);
const objs = {
1343: {
title: 'Fix issue 423',
duration: 60,
completed: true,
},
2454: {
title: 'Make new chart for dashboard',
duration: 120,
completed: false,
},
32323: {
title: 'Show validations in form',
duration: 180,
completed: true,
},
45434: {
title: 'Make new endpoint for login',
duration: 240,
completed: true,
},
}
const rt3 = Object.keys(objs).map(key => objs[key]);
console.log(rt3);