Round to at most 2 decimal places In JavaScript

πŸ‘¨πŸ½β€πŸ’» 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