3 ms·
> // Create a new bigint of 10^n. This turns out to be a bit > // faster than multiplying. > function exp10(n) { > return BigInt(`1${[...new Array(n)].map(()
by ballenf 6y ago
> // Create a new bigint of 10^n. This turns out to be a bit
> // faster than multiplying.
> function exp10(n) {
> return BigInt(`1${[...new Array(n)].map(() => > 0).join("")}`);
> }
Could we replace the 0 generation code with `'0'.repeat(n)`? Or `Array(n).fill(0).join("")` if old JS engine support is required?