连乘函数

function sum(x){
if(window.timer){
clearTimeout(window.timer)
}
const temp =(y)=>{
return sum(x*y)
}
temp.result = ()=>x
window.timer = setTimeout(()=>{
console.log(temp.result())
})
return temp
}
sum(1)(2)(5) //======>10
sum(5)(10)(2)//======>100
sum(2)(3)(4)(5)// =====>120

posted on 2018-10-10 09:06  geekjames1  阅读(360)  评论(0编辑  收藏  举报

导航