delete attribute from object inside an object array filtering by another attribute
let data = [ { name: "user", age: 99, coins: 5 }, { name: "user2", age: 99, coins: 5 } ]; function deleteProp(arr, prop, condition) { return arr.map(obj => { const copy = { ...obj }; if (obj[prop] === condition) { delete copy[prop]; } return copy; }); } console.log(deleteProp(data, "coins", 5));