7 lines
269 B
TypeScript
7 lines
269 B
TypeScript
export const formatCurrency = (amount:number) => {
|
|
// format number wirh 2 decimal places and a thousand separator
|
|
// amount is in cents
|
|
const formattedAmount = (amount/100).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
|
return(formattedAmount);
|
|
}
|
|
|