In Python I can use:
s = "x" * 10
xxxxxxxxxx
How in JavaScript, do I create a string n characters long without a loop?
In Python I can use:
s = "x" * 10
xxxxxxxxxx
How in JavaScript, do I create a string n characters long without a loop?
use String.repeat
"x".repeat(10);
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
On old browsers you could do
new Array(10).join('x')
new Array(11).join('x')
For 10 x
you need 11
in new Array so that 10th x is visible.