NeoSOFT interview question

Coding Round:- They asked to delete all the keys from a given object whose values are either null or undefined.

Interview Answer

Anonymous

23 May 2023

const obj = { one: null, two: 2, three: null, four: undefined, }; Object.keys(obj).forEach((key) => { if (!obj[key]) { delete obj[key] } }) console.log('obj:-', obj)