Is there a way to generate sequence of characters or numbers in javascript?
For example, I want to create array that contains eight 1s. I can do it with for loop, bu
Why not just a simple join and split?
function seq(len, value) { // create an array // join it using the value we want // split it return (new Array(len + 1)).join(value).split(""); } seq(10, "a"); ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"] seq(5, 1); ["1", "1", "1", "1", "1"]