var MANY_ZEROS = "000000000000000000"; function leftZeroPad(val, minLength) { if (typeof(val) != "string") val = String(val); return (MANY_ZEROS.substring(0, minLength - val.length)) + val; }
leftZeroPad(3, 2) ==> "03"
12378 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
var MANY_ZEROS = "000000000000000000"; function leftZeroPad(val, minLength) { if (typeof(val) != "string") val = String(val); return (MANY_ZEROS.substring(0, minLength - val.length)) + val; }
You need to create an account or log in to post comments to this site.