JSchallenger

Replace empty strings in object with null values

Viewed: 237
Attempted: 152
Solved: 39
// Write a function that takes an object as argument
// Some of the property values contain empty strings
// Replace empty strings and strings that contain only whitespace with null values
// Return the resulting object

function myFunction() {

return
}
Test Cases:
myFunction({ a: 'a', b: 'b', c: '' })
Expected
{ a: 'a', b: 'b', c: null }
myFunction({ a: '', b: 'b', c: ' ', d: 'd' })
Expected
{ a: null, b: 'b', c: null, d: 'd' }
myFunction({ a: 'a', b: 'b ', c: ' ', d: '' })
Expected
{ a: 'a', b: 'b ', c: null, d: null }