...
Code Block | ||
---|---|---|
| ||
let total = 0.00; for (const t of tasks) { const rate = roundToTwoDecimal(t.wage_at_moment); const hoursWorked = roundToTwoDecimal(roundToTwoDecimal(t.duration) / 60); total = roundToTwoDecimal(roundToTwoDecimal(total) + roundToTwoDecimal(rate * hoursWorked)); } |
In the final assignment, the rounding function is not called for the variables rate
and hours
simply because they were obviously rounded by the preceding lines. Notice that there are is no calls call for the terms t.duration
or constant term 60
either, because we know they are integers it’s an integer without any problematic fractional part.
...