repeat()
ES6+Returns a new string with a specified number of copies of the string.
Syntax
string.repeat(count)Parameters
count number Number of times to repeat the string
Return Value
string
A new string containing the specified number of copies
Examples
JavaScript
const str = 'abc';
console.log(str.repeat(3));
console.log('='.repeat(10)); Output:
// 'abcabcabc'
'=========='