AshKeys

Confessions and Confusions of a Freelance Fullstacker.

Ashok Mannolu Arunachalam, How toStringJS
Back

How to repeat a string in JavaScript

We can repeat a string using the repeat method.

const symbol = '*'
console.log(symbol.repeat(10))
// **********

This comes handy in case we want to put some symbols around the page.^_^

.repeat(0) will return an empty string. So, by controlling the numbers we can decide whether to show those symbols or not.