I am looking for a way to remove a specific key value pair within a nested array object in JavaScript. The goal is to get all the objects in the array after the removal. Can someone help me with this?
In the following object, I want to remove the mon
key value pair and retrieve the updated object using JavaScript.
var result = getObj(obj, "mon");
getObj(arr, month){
return arr.filter(element=>
if (element != month){
return element
}
);
}
var obj =[
{id: 1, mon: "Dec", tot: 1000},
{id: 2, mon: "tues", tot: 2000}
]
Desired Output:
[
{id: 1, tot: 1000},
{id: 2, tot: 2000}
]