

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to return a new string with a specified number of copies of an existing string with JavaScript?
Use the JavaScript repeat() method to return a new string with a specified number of copies of an existing string.
The following is the parameter −
- Count − Mention how many times you want to repeat the string
Example
You can try to run the following to repeat a string and display the result in a new string −
<!DOCTYPE html> <html> <body> <script> var a = "Welcome!"; document.write(a.repeat(3)); </script> </body> </html>
- Related Questions & Answers
- Counting number of vowels in a string with JavaScript
- Left pad a String with a specified String in Java
- How to check if a string starts with a specified Prefix string in Golang?
- How to check if a string ends with a specified Suffix string in Golang?
- How to remove two parts of a string with JavaScript?
- How to replicate a string for a specified number of times in MySQL?
- How to repeat a string for a specified number of times in Golang?
- Return a copy of the string with all occurrences of substring old replaced by new in Numpy
- How to convert a string with zeros to number in JavaScript?
- How to get a part of string after a specified character in JavaScript?
- Return a splitted array of the string based on all the specified separators - JavaScript
- How to return a string value version of the current number?
- How to return the number of images in a document with JavaScript?
- How to fill multiple copies of specified Object to a List in Java
- Return TRUE if the first string starts with a specific second string JavaScript
Advertisements