Confusing Currying Javascript

I have tried all kind of methods to do currying algorithm but still unable to pass all the test. Don’t know what I have done wrong. Can anyone tell me what’s wrong. PLEASE :sweat_smile: :sweat_smile:

   **Your code so far**

function curry(func){
 return function curried(...args){
   if (args.length>=2){
    return func.apply(this,args);
   }
   else{
     return function(...args2){
       return curried.apply(this,args.concat(args2));
     }
   }
   };
 }

function addTogether() {
 
if ([...arguments].every((ele)=>typeof ele==='number')){
return [...arguments].reduce((x,y)=>x+y);
}
 else{
   return undefined;
 }
}

let sumTwoAnd=curry(addTogether);
console.log(sumTwoAnd(5)(7));
console.log(sumTwoAnd(2,3));
console.log(sumTwoAnd(2,"3"));



   **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.198

Challenge: Arguments Optional

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.