Repeating a String
You want to repeat a string.
Create an array of n+1 nulls, and then join it with the repetition string as the glue:
Repeat method for Strings
You could also create a method for this in String prototype. It is as simple as that: