filmov
tv
Implement curry function in Javascript

Показать описание
Currying:
Currying is an advanced technique of working with functions. It’s used not only in JavaScript, but in other languages as well.
Please implement a curry() function, which accepts a function and return a curried one.
Here is an example:
const join = function (a, b, c) {
`${a}_${b}_${c}`
}
const curriedJoin = curry(join)
curriedJoin(1, 2, 3) // '1_2_3'
curriedJoin(1)(2, 3) // '1_2_3'
curriedJoin(1, 2)(3) // '1_2_3'
more to read:
Currying is an advanced technique of working with functions. It’s used not only in JavaScript, but in other languages as well.
Please implement a curry() function, which accepts a function and return a curried one.
Here is an example:
const join = function (a, b, c) {
`${a}_${b}_${c}`
}
const curriedJoin = curry(join)
curriedJoin(1, 2, 3) // '1_2_3'
curriedJoin(1)(2, 3) // '1_2_3'
curriedJoin(1, 2)(3) // '1_2_3'
more to read: