5 kyu
A Chain adding function
18,474 of 29,420gelus
Description:
We want to create a function that will add numbers together when called in succession.
add(1)(2); // == 3
We also want to be able to continue to add numbers to our chain.
add(1)(2)(3); // == 6
add(1)(2)(3)(4); // == 10
add(1)(2)(3)(4)(5); // == 15
and so on.
A single call should be equal to the number passed in.
add(1); // == 1
We should be able to store the returned values and reuse them.
var addTwo = add(2);
addTwo; // == 2
addTwo + 5; // == 7
addTwo(3); // == 5
addTwo(3)(5); // == 10
We can assume any number being passed in will be valid whole number.
Mathematics
Functional Programming
Puzzles
Similar Kata:
Stats:
Created | Jun 12, 2014 |
Published | Jun 12, 2014 |
Warriors Trained | 86751 |
Total Skips | 16793 |
Total Code Submissions | 124218 |
Total Times Completed | 29420 |
JavaScript Completions | 18474 |
Python Completions | 8506 |
TypeScript Completions | 1218 |
Ruby Completions | 546 |
C++ Completions | 1044 |
Total Stars | 2434 |
% of votes with a positive feedback rating | 82% of 2325 |
Total "Very Satisfied" Votes | 1685 |
Total "Somewhat Satisfied" Votes | 433 |
Total "Not Satisfied" Votes | 207 |