Object {Results:Array[3]}
Results:Array[3]
[0-2]
0:Object
id=1
name: "Rick"
upper:"0.67"
1:Object
id=2
name:'david'
upper:"0.46"
2:Object
id=3
name:'ashley'
upper:null
In the code snippet above, there is an array of objects displayed along with a variable called delete_id.
delete_id = 1,2
The delete_id variable holds values that correspond to the ids of objects that need to be deleted from the array. The expected output after deletion is shown below:
Object {Results:Array[1]}
Results:Array[3]
[0]
0:Object
id=3
name:'ashley'
upper:null
I am seeking assistance on how to achieve this functionality. I have attempted using the following function, but it only deletes the first id in the delete_id variable. For example, if delete_id = 2,3 then only 2 will be deleted. However, I want both 2 and 3 to be removed.
function removeID(delete_id) {
tabledata = tabledata.filter(function (obj) {
return delete_id.indexOf(obj.id);
});