Skip to main content
Version: Next

String Repeat

returns a new string which contains the specified number of copies of the input string

Description

The repeat method constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together.

Inputs

  • s (String): The string to repeat
  • times (Number): An integer between 0 and +Infinity, indicating the number of times to repeat the string.

Outputs

  • s.repeat(times) (String): A new string containing the specified number of copies of the given string