Skip to content

重复输出字符串

kinksteven edited this page Aug 4, 2017 · 3 revisions

既然是重复输出,那么我们也可以尝试用递归的方法。

参考答案 function repeat(str, num) { // 请把你的代码写在这里 var result=""; if(num>0){ return str+repeat(str,num-1); } else{ return result; } }

repeat("abc", 3);

Clone this wiki locally