5 kyu

Javascript Magic Function

506 of 540candrabeqx

Description:

Create function that:

  • accepts any number of parameters,
  • returns sum of every single parameter given,
  • any parameter that can not be parsed as a number will be counted as 0.
  • can be called infinitely,
  • the next function call will do the same thing, but also summing the last returned number.
MagicFunction(3) == 3; // should return true
MagicFunction(1, 2) == 3; // should return true
MagicFunction(1, 3)(2) == 6; // should return true
MagicFunction(1, 2)(3, 4, 5)(6)(7, 10) == 38; // should return true
Language Features
Functional Programming

More By Author:

Check out these other kata created by candrabeqx

Stats:

CreatedAug 12, 2015
PublishedAug 12, 2015
Warriors Trained2022
Total Skips233
Total Code Submissions10562
Total Times Completed540
JavaScript Completions506
Total Stars83
% of votes with a positive feedback rating88% of 106
Total "Very Satisfied" Votes89
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes9
Ad
Contributors
  • candrabeqx Avatar
  • jhoffner Avatar
  • JohanWiltink Avatar
Ad