im trying to remove from my JSON file one object from the array:
let json = [{
"name":"John",
"age":"29"
},
{
"name":"Billy",
"age":"45"
}];
I have an array that has the data to remove from JSON, it only has name in it
let remObj = ['John'];
Is it possible to remove only using name?
Edit:
I have tried Slice, Splice and filter
CodePudding user response:
Does this work for you?
let json = [{
"name":"John",
"age":"29"
},
{
"name":"Billy",
"age":"45"
}];
let remObj = ['John'];
const newJson = json.filter(p => !remObj.includes(p.name))
console.log(newJson)