.repeat() string method repeats a string a specified number of times. String will be concatenated.
count is an number between
Infinity, indicating the number of times to repeat a string. If the number is a decimal value, it is rounded down to the nearest integer.
Repeating a string a specified number of times:
console.log('Berlin is my favorite city! '.repeat(2));// Output: Berlin is my favorite city! Berlin is my favorite city!
The following is runnable, and demonstrates the use of the
- Anonymous contributorAnonymous contributor3077 total contributions
- Anonymous contributorAnonymous contributor51 total contributions
- mehboobali986 total contributions