Repeat a string multiple times:
console.log("ha".repeat(3)) // "hahaha"
console.log("=-".repeat(10)) // "=-=-=-=-=-=-=-=-=-="
console.log("x".repeat(0)) // ""
Useful for creating separators or padding:
function padLeft(str, length) {
let padding = " ".repeat(length - str.length)
return padding + str
}
console.log(padLeft("42", 5)) // " 42"