I have two array, could be integer array, string array or even object array, for demo purpose, I'll use integer array.
array1: array2:
0 99
1 1
101 5
2 100
100 97
5 101
4 4
I want to have a function return the array include all the information about the difference between two arrays. result would be:
0 -- {match:false,leftIndex:0 }
-- 99 {match:false: rightIndex:0}
1 1 {match:true: leftIndex:1,rightIndex:1}
-- 5 {match:false: rightIndex:2}
-- 100 {match:false: rightIndex:3}
-- 97 {match:false: rightIndex:4}
101 101 {match:false:leftIndex:2,rightIndex:5}
2 -- {match:false:leftIndex:3 }
100 -- {match:false:leftIndex:4 }
5 -- {match:false:leftIndex:5 }
4 4 {match:false:leftIndex:6,rightIndex:6}
What is the best way to approach this? I'm planning to use this function to display a side by side view for those two array using angularJS directive method. will that work?