How JavaScript uses the repeat function
This article mainly shows you "JavaScript how to use repeat function", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "JavaScript how to use repeat function" this article.
Repeat: generate a duplicate string consisting of n str, which can be modified to fill in an array, etc.
Function repeat (str, n) {let res ='; while (n) {if (n% 2 = 1) {res + = str;} if (n > 1) {str + = str;} n > > = 1;} return res} / / repeat ('123 repeat Magazine 3) = > 123123123 is all the contents of the article "how to use repeat functions by JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!