26 February, 2018

Add leading zero to make constant length of string using JavaScript

var acct1="12345678"
var acct=("000000000" + acct1).slice (-9);
document.write(acct);

output =012345678

2 comments:

  1. Input output
    123 000000123
    123456 000123456

    ReplyDelete
  2. Best of luck for your next blog.
    Thank you for such a wonderful article and sharing.God bless you.!
    dealsanddiscount

    ReplyDelete