1const removeEmpty = (obj) => {
2 let newObj = {};
3 Object.keys(obj).forEach((key) => {
4 if (obj[key] === Object(obj[key])) newObj[key] = removeEmpty(obj[key]);
5 else if (obj[key] !== undefined) newObj[key] = obj[key];
6 });
7 return newObj;
8};