Skip to content

Instantly share code, notes, and snippets.

View sonhoai27's full-sized avatar
🌴
On vacation

Kris Nguyen sonhoai27

🌴
On vacation
  • Ho Chi Minh City
View GitHub Profile
@sonhoai27
sonhoai27 / multiFilter.js
Created January 23, 2019 09:28 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple criteria.
/**
* Filters an array of objects with multiple criteria.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria as the property names
* @return {Array}
*/
function multiFilter(array, filters) {
const filterKeys = Object.keys(filters);
// filters all elements passing the criteria