Skip to content
Advertisement

Compare two 2D arrays & get intersection and differences

I have two multidimensional arrays with me..

JavaScript

I want to split above given arrays into three different arrays..

JavaScript

Advertisement

Answer

Convert arrays to a format, where array index is the sight_id:

JavaScript

Calculate the differences and intersection:

JavaScript

Convert arrays back to your format:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement