Is there a way to loop over an object and remove properties where the value matches a certain condition? In this case, I want to remove any properties that have no value.
Here is what I have:
var user = { first : 'John', last : 'Doe', city : 'Boston', state : 'MA', zip : '', birthdate : ''}
for(const [key, value] of Object.entries(user)){
if(!value){
delete user.key;
}
});
The code is detecting an empty value, but the delete function is not working;
Thanks!