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. Jun 26, 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.

  3. 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.

  4. 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.

  5. repeat() Return Value . Returns a new string containing the specified number of copies of the given string. Note: repeat() raises RangeError if repeat count is negative, infinity, or overflows maximum string size.

  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. 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.

  8. 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

  9. The repeat() method constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together. Syntax. /** . * str: String. * count: Number. */ let resultString = str.repeat(count); Parameters. count.

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