FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Size

15mins

Implement a function size(num) that sums numbers by accepting a number and allows for repeated calling with more numbers until it is called without arguments.

The function should:

  • Accept a number and return a function that continues accumulating the sum.
  • When called without arguments, return the total sum.

Examples

size(1)(2)(3)(); // 6 size(5)(10)(15)(20)(); // 50 size(7)(); // 7

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests