Money Formatting

Published by Deep Xavier in

Given a number, return a string which is formatted into US Dollars and cents!

Remember that:

  • You should round to two digits after the decimal point (even for integers).
  • Thousandths should be separated by commas.

Examples

dolladollaBills(10) ➞ "$10.00"

dolladollaBills(1000000) ➞ "$1,000,000.00"

dolladollaBills(-314159.2653) ➞ "-$314,159.27"

dolladollaBills(-56.99) ➞ "-$56.99"

Notes

There will be both negative and positive inputs.

Watch a quick demo on how Edabit works.