Answers for "how to filter multiple values from a json api"

0

how to filter multiple values from a json api

const filters = {forSale: true, color: 'blue'}; 
const filteredArray = array.filter(item => {
    let result = true;
    for(let key in filters) {
        if (item[key] !== filters[key]){
            result = false;
            break;
        }
    }
    return result;
})
Posted by: Guest on December-24-2021

Code answers related to "how to filter multiple values from a json api"

Code answers related to "Javascript"

Browse Popular Code Answers by Language