Add padding to string
Text that will be padded
Target length
Character to use as padding, defaults to space
Will pad start of text if true, or the end if false
Padded string
const now = new Date();const padded = now.getHours() + ':' + pad(now.getMinutes(), 2, '0');console.log(padded); // Output: "2:05" Copy
const now = new Date();const padded = now.getHours() + ':' + pad(now.getMinutes(), 2, '0');console.log(padded); // Output: "2:05"
Please use String.padStart & String.padEnd
String.padStart
String.padEnd
Add padding to string