> For the complete documentation index, see [llms.txt](https://mm.ricky.moe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mm.ricky.moe/interview/inverview-record/tou-tiao-mian-jing/bi-shi/shi-xian-sum123-6.md).

# 实现sum(1)(2)(3) = 6

这是一个柯里化题

```javascript
function add(x,y,z){
	return x+y+z
}


function curry(fn){
  judge = (...args) => args.length === fn.length ? fn(...args) : (arg) => judge(...args, arg)
  return judge
}

const sum = curry(add)

let ret = sum(1)(2)(3)
console.log(ret) // 6
```
