This function is functioning perfectly as intended.
function toUSD(amount): string {
// CONVERT number to $0.00 format
return new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
}).format(amount);
};
Here is how I currently implement it:
console.log(toUSD(123)); // result = $123.00
What modifications should be made to use it like this?
console.log((123).toUSD()); // output = $123.00