I have the following JSON, which I use as some kind of enum equivalent for javascript:
const blah = {
IV: {
name: "dIV",
value: 1
},
III: {
name: "dIII",
value: 2
},
II: {
name: "dII",
value: 3
},
I: {
name: "dI",
value: 4
}
};
I would like to filter all the objects by value
and then be able to loop through the result.
I tried to do something like:
let result = blah.find(x => x.value > 2);
result.each(function () {
console.log(this)
}
but this doesn't work and throws: blah.find is not a function.
The expected output would contain two elements:
II: { name: "dII", value: 3},
I: { name: "dI", value: 4}
Most of the examples I've found on the Internet use arrays in the JSON structure. Is there any option to achieve what I want or I need to modify the JSON structure and use an array? Cheers