Yahoo India Web Search

Search results

  1. The repeat() method returns a string with a number of copies of a string. The repeat() method returns a new string. The repeat() method does not change the original string.

  2. Sep 25, 2023 · The repeat() method of String values constructs and returns a new string which contains the specified number of copies of this string, concatenated together. Try it. Syntax. js. repeat(count) Parameters. count. An integer between 0 and +Infinity, indicating the number of times to repeat the string. Return value.

  3. Mar 14, 2024 · The repeat() method in JavaScript returns a new string by concatenating the original string a specified number of times. Syntax: string.repeat(count); Parameters: This method accepts a single parameter. count: count is an integer value that shows the number of times to repeat the given string.

  4. Apr 2, 2024 · This method is used to create a new string by repeating an existing string a specified number of times using the repeat () method. If a user provides the count to be 0 or negative, then an empty string is returned. Syntax: str.repeat(count); // Here str is your string.

  5. JavaScript String repeat () The repeat() method creates a new string by repeating the given string a specified number of times and returns it. Example. const holiday = "Happy holiday!"; // repeating the given string 3 times const result = holiday.repeat( 3 ); console.log(result);

  6. /** * Repeat a string `n`-times (recursive) * @param {String} s - The string you want to repeat. * @param {Number} n - The times to repeat the string. * @param {String} d - A delimiter between each string.

  7. Summary: in this tutorial, you’ll learn how to use the JavaScript string repeat() method to repeat a string a number of times. Introduction to the JavaScript String repeat() method The String.prototype.repeat() method returns a new string that repeats the original string a number of times.

  8. Repeat a string in JavaScript a number of times (24 answers) Closed 2 years ago. What is the best or most concise method for returning a string repeated an arbitrary amount of times? The following is my best shot so far: function repeat(s, n){ var a = []; while(a.length < n){ a.push(s); } return a.join(''); } javascript. string.

  9. Sep 18, 2023 · How to Repeat a String in JavaScript. JavaScript has a couple of ways to repeat a string. The two most common methods are using the built-in repeat() method and using a for loop. Let's explore these methods in more detail. Using the repeat() Method

  10. Jun 21, 2021 · The .repeat() string method repeats a string a specified number of times. String will be concatenated. Syntax