I have a JavaScript object that I use to store data for one user that can look like this:
output = {
id: "444",
trial: [1, 2, 3, 4, 5, 6, 7, 8, 9],
points: [0, 100, 50, 50, 0, 0, 0, 100, 50]
}
What I want is to query/filter this object, for example, to extract all trial numbers output.trial where output.points > 50.
I have found this in another post but it is not quite what I am looking for (it returns an empty array).
var result = $.grep(output, function(v) {
return v.points > 50;
});
In other words, I want to give a number of conditions and receive the instances of a name of my object where this is true (preferable as array). In this example:
result_after_query = [2, 8]
How can I achieve this?