I’ve been trying to figure out how to add period as a string in a certain place, here’s the code
function fixBalance(amount){
if(amount <= 99999999){
var amt = "0." + amount.toString().padStart(8, "0");
return Number(amt);
} else {
return false;
}
}
console.log(fixBalance(1));
console.log(fixBalance(1000));
console.log(fixBalance(10000000));
console.log(fixBalance(1000000000));
Basically, there are 8 spaces to the right of the 0
After it passes 8 numbers, I want numbers to keep going past the period
For example:
1 = 0.00000001
1000 = 0.00001000 or 0.00001
10000000 = 0.10000000 or 0.1
1000000000 = 10.00000000 or 10
If I were to put in 1000000000, it should be 10.00000000 or 10 as a numerical number
Trying to figure out how to do that with the else statement
Thank you!