I have an array of objects in jquery as below
{ ID: 12, Wt: 0.16, SizeID: null }
{ ID: 13, Wt: 0.05, SizeID: 1 }
{ ID: 14, Wt: 1, SizeID: 2 }
I want to filter this array of objects basis of value ID & SizeID properties. I am trying the below code
function findObject(data, rmID, sizeID) {
function search(a, i) {
if (a.ID === rmID && (sizeID == null || SizeID == sizeID)) {
index = i;
return true;
}
}
var index;
var d = JSON.parse(data);
if (d.some(search)) {
return data[index];
}
}
console.log(findObject(data, ID, sizeId));
I am getting an error d.some() is not a function.
Pls advise what am I doing wrong.