π¨π½βπ» Round to at most 2 decimal places In JavaScript
UseΒ Math.round(num * 100) / 100
Edit:Β to ensure things like 1.005 round correctly, we use
Math.round((num + Number.EPSILON) * 100) / 100
UseΒ Math.round(num * 100) / 100
Edit:Β to ensure things like 1.005 round correctly, we use
Math.round((num + Number.EPSILON) * 100) / 100