Makin' Money

Makin' Money

Without using Number.prototype.toLocaleString, write a function that takes an integer as an argument and formats it to look like a currency amount, including a dollar sign, commas, and a decimal (the last two digits will be the cents). E.g.:

formatMoney(123456789)  // returns $1,234,567.89
formatMoney(789)  // returns $7.89
formatMoney(89)  // returns $0.89
formatMoney(9)  // returns $0.09