My custom function is designed to transform a number or string from the format 'xxxxx.xx' to 'xx,xxx.xx' or xxxxx.xx to 'xx,xxx.xx'
function adjustFormat(input: number | string): string {
return `${+input.toLocaleString()}`;
}
console.log(adjustFormat(123456)); #123,456
console.log(adjustFormat(123456.78)); #123,456.78
console.log(adjustFormat('123456')); #123,456
console.log(adjustFormat('123456.78')); #123,456.78
=>
NaN
NaN
123456
123456.78