Skip to content

Commit

Permalink
Update replaceNullsWithEmptyStrings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmano1 authored May 17, 2024
1 parent 3242be7 commit 654a0cf
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions replaceNullsWithEmptyStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ function replaceNullsWithEmptyStrings(obj) {
}

// Example usage:
// var msgWithNulls = { name: "John", age: null, address: { street: "123 Main St", city: null } };
// var msgWithoutNulls = replaceNullsWithEmptyStrings(msgWithNulls);
// logger.info(msgWithoutNulls);
var msgWithNulls = {
name: "John",
age: null,
address: {
street: "123 Main St",
city: null
}
};
var msgWithoutNulls = replaceNullsWithEmptyStrings(msgWithNulls);
logger.info(msgWithoutNulls);

// Result:
// {
// name: "John",
// age: "",
// address: {
// street: "123 Main St",
// city: ""
// }
// }

0 comments on commit 654a0cf

Please sign in to comment.