Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function padLeft(width, char) {
- var pad = '';
- for (var i = 0; i < width; i++) {
- pad += char;
- }
- return pad;
- }
- var str = '1100';
- var pad = padLeft(8, '0');
- console.log(pad.substring(0, pad.length - str.length) + str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement