FrontendDeveloper.in

JavaScript question detail

How do you create specific number of copies of a string

The repeat() method is used to construct and return a new string which contains the specified number of copies of the string on which it was called, concatenated together. Remember that this method has been added to the ECMAScript 2015 specification. Let's take an example of Hello string to repeat it 4 times,

"Hello".repeat(4); // 'HelloHelloHelloHello'
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399