Trying to establish a default value for all NULL
objects has been quite the challenge. The current code looks like this:
private setDisplayAmount(summaries: summary[]): void {
summaries.map(t => {
// performing some operations, and then...
this.setDefaultValueForEmptyAmounts(t);
});
}
private setDefaultValueForEmptyAmounts(summary: Summary): void {
Object.values(summary.displayAmounts).map(property => property || 0);
}
The issue with setDefaultValueForEmptyAmounts
not functioning as expected is puzzling...
An alternative approach that works but lacks elegance is shown below:
private setDisplayAmount(summaries: summary[]): void {
summaries.map(t => {
// performing some operations, and then...
t.displayAmounts = {
OneAmount: t.oneAmt || 0,
TwoAmount: t.twoAmt || 0,
// ... repeating for all properties
};
});
}