Function Updated 30 May 2026
String.repeat(times)
Repeats a string a specified number times and returns the new value.
Parameters
timesnumberrequiredHow many times to repeat the string.
Returns
A new string that repeats the string a specified number times. Does not change the initial string.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
/* Declare a text to repeat */
var text = "abc";
/* Repeat text 3x */
text = text.repeat(3);
/* Output contents of text variable */
write(text);
}#
The template above produces this output:
abcabcabc