To filter an array or object by checking multiple values with JavaScript, we use the filter
method.
For instance, we write
const find = myArray.filter((result) => {
return result.param1 === "string1" && result.param2 === "string2";
});
to call myArray.filter
with a function that checks if the result
object in myArray
that’s being looped through has the params1
property equal to 'string1'
and params2
equals to 'string2'
.
An array with the objects that meets the condition is returned.