console.log(zeroFill(11090, 8));
console.log(zeroFill(120, 2));
console.log(zeroFill(120, 5));
function zeroFill(num,val)
{
var temp = num.toString().split('');
var gen = val-(temp.length);
var arr = [];
if(val<=(temp.length))
{
return 'Invalid';
}
else
{
for(var i =0 ; i<gen ; i++)
{
arr[i] = '0';
}
var ar = (arr +','+ temp);
return ar;
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: