js repeat
The repeat() method in JavaScript is used to create a new string by repeating a given string a certain number of times.
Syntax:
string.repeat(count)
string: The string to be repeated.count: The number of times the string should be repeated.
Example:
const str = 'Hello';
console.log(str.repeat(3)); // Output: 'HelloHelloHello'
In the above example, the repeat() method is used to repeat the string 'Hello' three times, resulting in the output 'HelloHelloHello'.
原文地址: https://www.cveoy.top/t/topic/ufe 著作权归作者所有。请勿转载和采集!