function currying(func) {
//I need to complete this for all diiferent forms of add
}
//1st form
const add = currying(function (a, b) {
return a + b;
})
add(1, 2) //should yield 3
add(1)(2) //should yield 3
//second form
const add = currying(function (a, b, c) {
return a + b + c;
})
add(1, 2)(3) //should yield 6
add(1)(2)(3) //should yield 6
add(1, 2, 3) //should yield 6
//third form
const add = currying(function (a, b, c, d) {
return a + b + c + d;
})
const a11 = add(1)
a11(2)(3)(4) //should yield 9
a11(2, 3, 4) //should yield 9
How to complete the top most "currying" function for all these cases? "Currying" function must return correct answer for any of these kind of function calls.