Sunny-117 / js-challenges

✨✨✨ Challenge your JavaScript programming limits step by step

Home Page:https://juejin.cn/column/7244788137410560055

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sum(x,y)和sum(x)(y)

Sunny-117 opened this issue · comments

答案一
function sum(a,b){
  if(b) {
    return a+b
  }else{
    return function(c){
      return a+c
    }
  }
}
答案二
function sum(){
  var arg=arguments
  if(arg.length==2) {
    return arg[0]+arg[1];
  }else{
    return function(c){
      return arg[0]+c
    }
  }
}