Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to find intersecting data in an array?
There is an array of services, the elements of which are also an array. It has a beginning, an end, a workplace, a master.
[[1443646800,1443649500,4,4],[1443646800,1443649500,4,1],[1443646800,1443649500,3,4],[1443646800,1443649500,3,1],[1443650400,1443669300,3,4],[1443650400,1443669300,4,1],[1443650400,1443669300,4,4],[1443650400,1443672000,3,1],[1443671700,1443690900,3,4],[1443671700,1443696300,4,4],[1443675600,1443680100,3,1],[1443675600,1443680100,4,1],[1443680700,1443690900,4,1],[1443680700,1443690900,3,1],[1443691800,1443696300,3,4],[1443691800,1443717000,4,1],[1443691800,1443724200,3,1],[1443700800,1443717000,4,4],[1443700800,1443717000,3,4],[1443721800,1443724200,3,4],[1443721800,1443724200,4,1],[1443721800,1443740400,4,4],[1443727800,1443733200,4,1],[1443727800,1443733200,3,1],[1443727800,1443740400,3,4],[1443736800,1443737700,4,1],[1443736800,1443737700,3,1],[1443738600,1443740400,3,1],[1443738600,1443740400,4,1]]
[time: [[1443646800,1443649500],[1443646800,1443649500]], workstations : [1,5], workers: [1,3]]
Answer the question
In order to leave comments, you need to log in
The solution turned out to be this
jsfiddle.net/m8vxw3tb/4
var result = {
time: [],
workstations : [],
workers: []
};
for (var i = 0; i < data.length; ++i) {
!~result.time.indexOf(JSON.stringify([data[i][0], data[i][1]])) && result.time.push(JSON.stringify([data[i][0], data[i][1]]));
!~result.workstations.indexOf(data[i][2]) && result.workstations.push(data[i][2]);
!~result.workers.indexOf(data[i][3])&& result.workers.push(data[i][3]);
}
console.log(result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question