Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Strings</h1> <h2>The repeat() Method</h2> <p>repeat() returns a new string with a number of copies of a string:</p> <p id="demo"></p> <p>repeat() is not supported in Internet Explorer.</p> <script> let text = "Hello world!"; let result = text.repeat(4); document.getElementById("demo").innerHTML = result; </script> </body> </html>