The repeat(count) method

The repeat() method of a string constructs and returns a new string which contains the specified number of copies on which it was called, concatenated together. Here is an example to demonstrate this:

console.log("a".repeat(6)); //Output "aaaaaa"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.