DEV Community

Discussion on: Daily Challenge #49 - Dollars and Cents

Collapse
 
jasman7799 profile image
Jarod Smith
const formatDollars = money => `$${money.toFixed(2)}`;


`
love js

Collapse
 
saschalalala profile image
Sascha • Edited

Mind rounding "errors":

formatDollars(.126)
> '$0.13'

Same happens in python:

print(f"{123.126:.2f}")
123.13
Collapse
 
thepeoplesbourgeois profile image
Josh

It rounded up, though, so is that an error? It seems like expected behavior to me.