JS rounding with decimal point

 

The value passed in the background is integerized first 

var a = parseInt(10);
var b = parseInt(3);
var c = (a / b).toFixed(3)*100; After division, truncate the last three decimal places and then *100
var myl = Math.round( c / 1); then round up

 var =myl.toString() + "%"+" add a percentage at the end  

Get the result as 30%

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324740101&siteId=291194637