I'm trying to merge duplicate entries in an array of objects by creating a new array.
I don't know how to check for duplicated without looping through the new array, which then messes me up when trying to push stuff because it does it every time for the outer loop.
How should I do this properly?
var arr=[0];
for (var k in data) {
var name = data[k].name;
var item = data[k];
//check if already in array
for (var l in arr){
if (arr[l].name == name){
arr[l].value = arr[l.value] + ';;' + item.value;
} else {
arr.push(item);
}
}
}
for..inis for looping objects, not arrays.