# Using destructuring assignment to dynamically create new functions in JavaScript

> Using destructuring assignment to dynamically create new functions in JavaScript. A short Today I Learned note from the Graffino team.

- URL: https://graffino.com/til/using-destructuring-assignment-to-dynamically-create-new-functions-in-javascript
- Author: Nick Ciolpan
- Channel: javascript
- Published: 2021-05-25
- Updated: 2021-05-25

```
// www.codewars.com/kata/525f3eda17c7cd9f9e000b39

const curry = (operand, operator) => (!operator) ? operand : operator(operand);

const [zero, one, two, three, four, five, six, seven, eight, nine] =
  [0,1,2,3,4,5,6,7,8,9].map(operand => ((operator) => curry(operand, operator)));

const plus = (first) => (second) => second + first;
const minus = (first) => (second) => second - first;
const times = (first) => (second) => second * first;
const dividedBy = (first) => (second) => Math.floor(second / first);
```
