Implement a compactObject function
compactObject
is a utility function which can take nested objects and arrays and remove any falsy
values from them.
The values false
, null
, ''
, undefined
, 0
and NaN
are considered falsy.
1. Basic implementation
Do not mutate the original array. Consider only JSON serializable values will be passed to input.
Further Reading
I strongly encourage you to explore and tackle additional questions in my Recursion Questions for Frontend Interviews blog series.
By doing so, you can enhance your understanding and proficiency with recursion, preparing you to excel in your upcoming frontend interviews.
Wishing you best. Happy Interviewing 🫡.