I'm trying to pass a parameter to a function so that I can call my array object elements multiple times (since I have them quite a lot, returned from the sql query).
removeDuplicates(arr, x){
var tmp = [];
var tmp2=[];
for(let i = 0; i < 50; i++){
if(tmp.indexOf(arr[i].id) == -1){
tmp.push(arr[i].id); //always id
tmp2.push(arr[i].x); //for example arr[i].name
}
}
return tmp2;
}
If I do it like that and call the method like this:
removeDuplicates(arraytag2, arraytag2.name);
it doesn't work.