Skip to content

Instantly share code, notes, and snippets.

@shime shime/
Created Nov 19, 2014

What would you like to do?
text from kata at solution is in 3 lines of code.

We want to create a function that will add numbers together when called in succession.

add(1)(2) == 3 // true

We also want to be able to continue to add numbers to our chain.

add(1)(2)(3) == 6 // true
add(1)(2)(3)(4) == 10 // true
add(1)(2)(3)(4)(5) == 15 // true

and so on.

A single call should return the number passed in.

add(1) == 1 // true

and we should be able to store the result and reuse it.

var addTwo = add(2);
addTwo == 2 // true
addTwo(3) == 5 // true
addTwo(3)(5) == 10 // true

We can assume any number being passed in will be valid javascript number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.