Can't understand how to loop through all arrays and push it into one avoiding duplicates, so I can have the result like:
['All', 'Images', 'Video']
So far, now I have the following, but it is not that expected:
let filterize = function(el, config){
let target = document.getElementById(el);
let arrayCommon;
for(let value in config) {
arrayCommon = [...new Set([...config[value].filter])];
}
console.log(arrayCommon)
}
var filterize_init = new filterize('Filtered', {
element_1: {
filter: ['All', 'Image']
},
element_2: {
filter: ['All', 'Video']
}
})
<div class="wrapper">
<div id="Filtered" class="filter-content">
</div>
</div>
Can anyone help ?
Setcreated before the loop, add to the set inside the loop, then convert set to array after the loop. Either that or just.concat()the individual arrays to form a master list with duplicates, then remove the duplicates from the full list.