@param -> items : Conjunto de datos a recorrer, este debe de ser un Array de Objetos. @param -> filters : Conjunto de criterior y valores a buscar, el parametro debe de ser de tipo objeto dentro de la cual debe de haber objetos de tipo array, como se muestra en el ejemplo de las notas. const multiFilter = (items, filters) => { const filterKeys = Object.keys(filters); return items.filter(item => { return filterKeys.every(key => { if (!filters[key].length) return true; if (Array.isArray(item[key])) { return item[key].some(keyEle => filters[key].includes(keyEle)); } return filters[key].includes(item[key]); }); }); };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter