如何在javascript循环中重复字符串

问题描述 投票:0回答:1

[我正在尝试编写一个通过在此函数内循环来简单地将字符串重复3次的函数:

    repeatString('hey', 3) // returns 'heyheyhey'

到目前为止,我有以下代码,并且正在尝试循环;

    const repeatString = function() {

     }

   module.exports = repeatString
string loops repeat
1个回答
0
投票

这是我想出并工作的代码!

© www.soinside.com 2019 - 2024. All rights reserved.