I have a very large array of objects that I need the keys remove from. I can’t seem to get my head around how to make this happen with list of keys.
https://jsfiddle.net/rgfx_fiddle/cvoz7ygm/15/
const sections = [
{
municipality: "Monte De Oca",
office: "Oficina de la Mujer"
},
{
case_number: "MDO-ABCDEFG",
identification: "Cédula",
id_number: "123456789"
}
];
const removeThis = [
"municipality",
"id_number"
]
function filter(data) {
for(var i in data){
if(removeThis.indexOf(i) != -1){
delete data[i];
}
}
return data;
}
console.log(filter(sections));