If I have a specific filter set up like this:
filter = [ {key: "pl", value: 3}, {key: "sh", value: 2} ]
I am looking to use this filter to search through the following JavaScript object:
var data = [
{title: "The Uncertainty of the Poet ",
pl: 3,
si: 2,
va: 3,
te: 0,
co: 0,
or: 4,
sh: 2,
po: 0,
li: 0,
ar: 5
},
{
title: "Direction",
pl: 4,
si: 3,
va: 1,
te: 3,
co: 0,
or: 3,
sh: 2,
po: 0,
li: 0,
ar: 5
}
...
]
I attempted the following code but it did not work as expected:
var result = data.filter(function(d){
for (item in filter) {
return d.key==d.value;
}