Add Preceding Zeros to Score


/ Published in: JavaScript
Save to your folder(s)

Example:

`addZeros((549).toString(),7);`

Returns:

`"0000549"`


Copy this code and paste it in your HTML
  1. function addZeros(score,digits) {
  2. if(score.length >= digits) { return score; }
  3. return addZeros("0"+score,digits);
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.