number = 1
converted = number.toString().padStart(3, '0')
console.log(converted)
// Expected output
" 001 "
function numberWithSpaces(x) {
return x.toString().replace(/B(?=(d{3})+(?!d))/g, " ");
}
var x = parseFloat('9.656');
x.toFixed(0); // returns 10
x.toFixed(2); // returns 9.66
x.toFixed(4); // returns 9.6560
x.toFixed(6);
function m(n,d){x=(''+n).length,p=Math.pow,d=p(10,d)
x-=x%3
return Math.round(n*d/p(10,x))/d+" kMGTPE"[x/3]}