JavaScript Repeat
repeat() builds a new string by concatenating a given number of copies of the original. Pass 0 for an empty string; a negative count throws a RangeError.
Syntax
str.repeat(count) Examples
| Input | Arguments | Output |
|---|---|---|
| "ab" | 3 | "ababab" |
Gotchas
- A negative or infinite count throws a RangeError.
Try it live
Type your input and see Repeat transform it instantly.
Want to go further? Chain Repeat with other functions, pipe one output into the next and watch your data transform in the visual Playground.