js show 3 number after decimal code example
Example 1: javascript show 2 decimal places
var myNumber=12.2345;
var myNumberWithTwoDecimalPlaces=parseFloat(myNumber).toFixed(2); //12.23
Example 2: 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);