我想通过 codewars 的测验 - https://www.codewars.com/kata/53cf7e37e9876c35a60002c9/train/javascript,但我无法避免通过错误:“TypeError: add(...) is not a function”
function curryPartial(){
let args= [...arguments]
let fn = args[0]
console.log(fn.length)
function cur(){
let argsCur= [...arguments]
return curryPartial(...args,...argsCur)
}
cur.valueOf = ()=>{
//return args.reduce((a,b)=>a+b)
// console.log(...args)
// const res = +fn(...args.slice(1))
// return res
}
return cur
}
function add(a, b, c) {
return a + b + c;
}
console.log(+curryPartial(add(1,2)(3)))
如何避免此错误以通过测验?
尚方宝剑之说
相关分类