The repeat() method returns a new string with a specified number of copies.
The repeat() method returns a new string with a specified number of copies.
string.repeat(count)
Parameter | Require | Description |
---|---|---|
count | Required. | The number of times the original string should be repeated in the new string |
A String, a new string containing copies of the original string
Make a new string by copying a string twice:
//Make a new string by copying a string twice: var str = "Hello world!"; console.log(str.repeat(2));