The String.prototype.repeat() function repeats a given string for a number of time. The count is given as parameter to the function.
The general syntax is given below.
string.repeat(count);
Usage
<!DOCTYPE html>
<html>
<head>
<title>String.prototype.repeat()</title>
<meta charset="utf-8">
</head>
<body>
<main>
<h1 id="out">Output here</h1>
<p>Program to repeat a string using String.prototype.repeat() JavaScript function.</p>
</main>
<script>
var str = "Elephant";
document.getElementById("out").innerHTML = str.repeat(3);
</script>
</body>
</html>