javascript round to 2 digits
snippet in javascript

javascript round decimal 2 digits

user5183

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

javascript round to 2 digits

user833

var num = 2;
var roundedString = num.toFixed(2);// 2.00

how to numeric value is after point 2 values in javascript

user9215

var totalAmount = 0;
totalAmount = Number($("#sub_amount").val()) + Number($("#vat_amount").val());
totalAmount = totalAmount.toFixed(2);
$('#total_amount').val(totalAmount);
//@sujay

rounding number to x decimals javascript

user5343

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

best way to round to two typescript

user471

const roundTo = function(num: number, places: number) {
  const factor = 10 ** places;
  return Math.round(num * factor) / factor;
};

roundTo(123.456, 2);  // 123.46
roundTo(123.3210, 2);  // 123.32
roundTo(123.456, 1);  // 123.5
roundTo(123, 2);  // 123