JAVASCRIPT

HOW TO PAD NUMBERS WITH ZEROES IN JAVASCRIPT

THE NUMBERS var numA = 123; var numB = 123.45;   LEADING ZEROES var padA = "000" + numA;   TRAILING ZEROES var padB = numB + "000";

CONCAT WITH STRING OF ZEROES

01

THE NUMBERS var numA = 123; var numB = 123.45;   CONVERT TO STRING numA = numA.toString(); numB = numB.toString();

PAD STRING FUNCTION

02

LEADING ZEROES var padA = numA.padStart(5, 0);   TRAILING ZEROES var padB = numB.padEnd(8, 0);