数组求和
let list = [1,2,3,4,5,6]
方法一:
function f(i) {
return i >=list.length ? 0:list[i]+f(i+1)
}
方法二:
function fl(i) {
let list = [1,2,3,4,5,6]
let res;
for(let n=0;i<list.length; i++) {
n+=list[i]
res = n
}
return res
}