function repeatStringNumTimes(string,times){
if(times<=0){
return "";
}
if(times===1){
return string;
}
else
return string+repeatStringNumTimes(string,times--);
}
alert(repeatStringNumTimes("abc",3));

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
楼主,你这是一直在循环,当然要出现溢出了
每次传入的都是 使用之后减一,每次都是3,当然溢出,除非times 在function外