Update:
Original:
Could you tell me why toLocaleString()
is not working here? It works in all other places. I need it to give 1000 separators
. Any clue or work around?
forEach(budgetList, async (b: Budget) => {
const budget: Budget = find(this.oldBudgetList, (budget: Budget) => {
return b.budgetGroup.name == budget.budgetGroup.name;
});
if (budget == null) {//new item
const log = this.logProvider.getLogDetails(`Budget : ${b.budgetGroup.name}`, `Added ${b.amount.toLocaleString()}`, 'project', project.id);
await this.logProvider.createLog(log, project.id);//add log
}
});
Runtime:
Another place and works well!
const log = this.logProvider.getLogDetails('Project : Budget', `Budget changed from ${this.oldBudgetValue.toLocaleString()} to ${project.budget.toLocaleString()}`, 'project', project.id);
await this.logProvider.createLog(log, project.id);//add log
If the value is of type String
, you could do e.g.
Number(b.amount).toLocaleString()
(which was what was working in OP's case)
Other options could be
parseInt('number as string').toLocaleString()
parseFloat('number as string').toLocaleString()