js rounding function toFixed(), the parameter inside is the number of decimal places to retain. Copy code The code is as follows: <br>document.write("<h1>JS example of retaining two decimal places</h1><br>"); <br>var a=2.1512131231231321; <br>document.write("Original value: " a "<br>"); <br>document.write("Two decimal points:" a.toFixed(2) "<br>Four decimal points" a.toFixed(4)); <br></ script> <br> </div>