My JSON object is called idAndNames.json;
[
{ "id":"1", "name":"name1"},
{ "id":"2", "name":"name2"},
{ "id":"3", "name":"name3"}
]
I'm looking to filter it by ID and name
function applyFilter(id, valueItem) {
return id <= valueItem;
}
//Using Immutable.js, I converted the JSON to an array -> fromJS(idAndNames);
idAndNamesArray.filter(item => applyFilter(item.get('id'), valueItem));
However, I'm facing issues filtering by ID or name
For instance, when valueItem=1 as an integer, I receive the error: "Expected Array or iterable object of values"
On the other hand, when valueItem="1" as a string, there is no error but the filter doesn't work
Could you please assist me in finding the correct approach? Thank you