Describe the issue // question // bug
.toFixed used to set digits after decimal, but also converts the number to a string datatype
Location in Code // Steps To Reproduce
Currently in the Promise.all in index.js
Line 64 in index.js
user.totalSpent = totalSpent.toFixed(2);
Expected behavior
Using .toFixed to set the number of digits after the decimal to 2
to display $dollars.cents for user bills
Additional context
Tried to use parseInt(), but found that this rounded the number to an integer without the float digits.
Maybe need to try splitting the string at the period, converting both sides of decimal to respective numeric values, then adding back together? (Must be a cleaner way)
I don't think we'll need to use this 'number' again (within spec context)
but still seems like it should actually be a number.
Look out for issues that could arise from this altered datatype later if not resolved.
Describe the issue // question // bug .toFixed used to set digits after decimal, but also converts the number to a string datatype
Location in Code // Steps To Reproduce Currently in the Promise.all in index.js Line 64 in index.js
user.totalSpent = totalSpent.toFixed(2);
Expected behavior Using .toFixed to set the number of digits after the decimal to 2 to display $dollars.cents for user bills
Additional context Tried to use
parseInt()
, but found that this rounded the number to an integer without the float digits. Maybe need to try splitting the string at the period, converting both sides of decimal to respective numeric values, then adding back together? (Must be a cleaner way)I don't think we'll need to use this 'number' again (within spec context) but still seems like it should actually be a number. Look out for issues that could arise from this altered datatype later if not resolved.