-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
43 lines (41 loc) · 823 Bytes
/
test.js
File metadata and controls
43 lines (41 loc) · 823 Bytes
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
var findIndex = (atime,projection) => {
let ind = 0;
let found = false;
projection.forEach((task,i) => {
if(!found){
if(atime<task.start){
ind = i;
found = true;
}else if(i === projection.length-1){
ind = projection.length;
found = true;
}
}
});
return ind;
}
let projection = [
{
owner: "P1",
line: "LINE 0",
index: 0,
duration: 30,
start: 0,
},
{
owner: "P3",
line: "LINE 0",
index: 0,
duration: 30,
start: 0,
},
{
owner: "P2",
line:"LINE 0",
index: 1,
duration: 60,
start: 180,
},
];
atime = 300;
console.log(findIndex(atime,projection));