March 18, 2018 | 1 min read
Currying was something that went over my head, but I wish I knew. It wasn’t until I was approached with a problem.
THE PROBLEM: Write a function the can perform the following, add3(1)(2)(3).
What is currying? Currying is when we take function and break it down to a sequence of functions that takes only small parts of the argument.
Why use it?
- easier to reuse
- don’t need all params at once
Back to our problem! We can solve this using the following:
add3 = a => b => c => a + b + c
Then we can call it a handful of ways: