const array = [
[
'USA',
'Apple',
'New York',
'Military'
],
[
'INDIA',
'Mango',
'New delhi',
'AirCraft'
],
[
'United Kingdom',
'Apple',
'London',
'Fighter'
]
]
var outputArray = [];
var count = 0;
var start = false;
for (j = 0; j < array.length; j++) {
for (k = 0; k < outputArray.length; k++) {
if ( array[j][1] == outputArray[k][1] ) {
start = true;
}
}
count++;
if (count == 0 && start == false) {
outputArray.push(array[j][1]);
}
start = false;
count = 0;
}
document.write(outputArray);
I am trying to filter out non duplicate from array of array but didn't get success
I was expecting only
[ 'INDIA', 'Mango', 'New delhi', 'AirCraft' ],
It should only check with index of 1 if duplicate matches found just discard this from array and print rest.