Answers for "how to make number input to always display 2 decimal places in javascript"

21

js number 2 decimal places

(3.141596).toFixed(2);	// 3.14
Posted by: Guest on August-13-2020
0

get the integer after decimal in javascript

const number = 2.3;
const numberAfterDecimal = parseInt((number % 1).toFixed(2).substring(2));
const numberBeforeDecimal = parseInt(number);

console.log("value before decimal", numberBeforeDecimal);
console.log("value after decimal", numberAfterDecimal);
Posted by: Guest on May-25-2021

Code answers related to "how to make number input to always display 2 decimal places in javascript"

Browse Popular Code Answers by Language