I want to remove all test keys from an array of objects. So each object that contains test should be processed by the function, to remove that key.
const obj = [{
address: "asda",
city: "asdasd",
country: "1",
description: {
test: 123,
name: 'name'
},
id: {
test: 152,
idB: 'n'
},
code: "asdas ",
test: 156,
}]
const arr = () => {
const newKeys = obj.flatMap(item => Object.entries(item))
const condition = newKeys.filter(i => i[0] !== 'test')
return Object.fromEntries(condition)
}
console.log(arr())
Now i did to remove only the test from main object but i can't figure out how to remove each test from the rest objects inside main object. How to do this in my code?