String.repeat(times) Last updated: 13. Nov 2023

Repeats a string a specified number times and returns the new value.

Parameters

Name Type Description
times int How 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

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    /* Declare a text to repeat */
    var text = "abc";
    
    /* Repeat text 3x */
    text = text.repeat(3);
    
    /* Output contents of text variable */
    write(text);
}#

Output

The #JS code above produces the output shown below:
abcabcabc