โ06-15-2022 12:32 PM
Hi All,
I have a scenario in which I have to add leading 0 to make all over length as 9 of the value. If the value is of length 1 then I will add 8 zeros and if the value is of 4 digit lenght then i will add 5 zeros to make it total 9 digits as length.
For Example
Input:
1
2
16
188
1235
Output:
000000001
000000002
000000016
000000188
000001235
Please help
โ06-15-2022 02:05 PM
use .concat(โ00000000โ).concat($Input).slice(-8)
โ06-16-2022 01:22 AM
This is not working. Can you explain little more
$value : 1234
I want it as 000001234
$value : 12345
I want it as 000012345
total length = 9
โ06-16-2022 01:45 AM
$value.toString().length < 9? โ0โ.repeat(9 - $value.toString().length) +$value: $value
This is working
โ06-16-2022 05:31 AM
text1 = โ000000000โ; //length you want
text2 = โ1234โ;
result = โ000000000โ.concat(text2);
0000000001234
//returns last number of characters
let result2 = result.slice(-9); //length you want
000001234
โ0โ.repeat(9).concat(text2).slice(-9)