AlgoDaily Solution

1function curry(func) {
2  // ...args collects arguments as array
3  return function curriedFunc(...args) {
4    // Check if current args passed equals the number of args func expects
5    if (args.length >= func.length) {
6      // if args length equals the expected number, pass into func (spread)
7      return func(...args);
8    } else {
9      /* Else, we return a function that collects the next arguments passed and 
10      recursively call curriedFunc */
11      return function (...next) {
12        return curriedFunc(...args, ...next);
13      };
14    }
15  };
16}

Community Solutions

Community solutions are only available for premium users.

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.

JAVASCRIPT
OUTPUT
Results will appear here.