This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.

Smartphone icons created by Freepik - Flaticon

JavaScript Strings

The padEnd() Method

The padEnd() method pads a string at the end.

It pads the string with another string (multiple times) until it reaches a given length.

let text = "5";
text = text.padEnd(4,"0");

document.getElementById("demo").innerHTML = text;
Legend

original string pad the original string new string