I'm given numbers in cents:
eg.
102042
982123
121212
I want to convert them to dollars. I figured the easiest way to do this is to convert the digits into a string and add a decimal.
eg.
1020.42
9821.23
1212.12
I'm currently doing this but it only rounds to 1 decimal. What would I need to do it make it round to 2 decimals?
var number = 102042
number.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0]
UPDATE: I found out what my issue was. It wasn't the rounding but the fact that I combined a lodash filter to a division incorrectly. Thanks again!