var arr = [1,3,2,7,5,9,11];
function sum(arr){
var total = 0;
var fun = function(arrs){
if(arrs.length > 0){
total += arrs.pop();
fun(arrs);
}
}
fun(arr);
return total;
}
时间: 2024-09-30 15:36:23
var arr = [1,3,2,7,5,9,11];
function sum(arr){
var total = 0;
var fun = function(arrs){
if(arrs.length > 0){
total += arrs.pop();
fun(arrs);
}
}
fun(arr);
return total;
}