javascript round 2 decimals
snippet in javascript

javascript round decimal 2 digits

user5721

var numb = 123.23454;
numb = numb.toFixed(2);

javascript round 2 decimals

user5070

var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"

javascript convert int to float with 2 decimal places

user8732

float_num.toFixed(2);

round number 2 decimals javascript

user9977

Math.round((num + Number.EPSILON) * 100) / 100

rounding number to x decimals javascript

user4585

let num = 12.5452411;
num = num.toFixed(3); // 12.545

js number with four decimal places

user7586

var myNumber = 2;

myNumber.toFixed(2); //returns "2.00"
myNumber.toFixed(1); //returns "2.0"