How to use the String repeat() method in JavaScript

The JavaScript string repeat() method is used to repeat string values as many times as you specify inside the parenthesis:

let hipHop = "hiphop ".repeat(5)

console.log(hipHop)
// "hiphop hiphop hiphop hiphop hiphop "

Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊

Kofi

Share & Discuss on