javascript 2 digit code example

Example 1: javascript snumber two decimal places as string

let money = 1.6;

money.toFixed(2); // 1.60

Example 2: javascript 1 + "1"

console.log(10+"1"); //101
console.log(10-"1"); //9

Example 3: how to numeric value is after point 2 values in javascript

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

Example 4: concantene number in js

Use "" + 5 + 6 to force it to strings. 
This works with numerical variables too:

var a = 5;
var b = 6;
console.log("" + a + b);

Example 5: javascript two digits number

var myNumber = 7;
var formattedNumber = ("0" + myNumber).slice(-2);
console.log(formattedNumber);

Example 6: two digit js''

var myNumber = 8;
var formattedNumber = ("0" + myNumber).slice(-2);
console.log(formattedNumber);