The formula is a bit long but works:
function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, "") } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2
The formula is a bit long but works:
function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, "") } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2