FastPrepCollect Arguments Until the Function Is Full
Problems/Collect Arguments Until the Function Is Full

Collect Arguments Until the Function Is Full

Rippling logoRippling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Every rule here is our choice. The returned function gathers arguments until it has as many as the length of fn, then runs fn with everything gathered, extras included. Each gathering function keeps its own list, so reusing one never changes another. A call with no arguments adds nothing but counts as a call, undefined and null count as arguments, and the call that finishes the gathering supplies this. The step format, the tests and the examples are ours too.

Two reports back this task. One comes from a frontend first round and one from a senior frontend technical round. Each pairs this topic with a second function task (debouncing in one, binding in the other). Neither gives a signature, a rule for extra arguments, or a rule for reuse.

This version calls your function and checks what each call returns. It cannot check how you write the closure, only what comes back. The editorial covers the explanation side.

Our version is about 55% the same as the reported questions.

Write collectArgs(fn). It takes a function fn and returns a new function that gathers arguments over one or more calls and runs fn once it has enough.

Let need be fn.length: the number of parameters fn declares before the first one that has a default value or a rest marker (...). Each call to a gathering function adds its arguments to the ones gathered before it:

  • If there are now at least need arguments, call fn with all of them, in order, and return what fn returns. Extra arguments are passed on too.
  • Otherwise, return a new function that keeps gathering.

Rules for this exercise:

  • A gathering function remembers only the arguments gathered up to its own call. Calling it again starts from the same place, and one function never changes what another one has gathered.
  • A call with no arguments adds nothing, but it still counts as a call. It returns a gathering function, or runs fn when need is 0.
  • undefined and null count as arguments like any other value.
  • The call that completes the gathering supplies this for fn. Earlier calls do not.
  • If fn throws, the error goes to the caller. The gathering functions still work afterwards.

How the tests are written

Each test is a short script: a list of steps that run in order. {"let": "x", "value": V} makes a value called x. A value written as {"$js": "expression"} is the result of that JavaScript expression, and the expression may use names made earlier. {"call": "f", "args": [...]} calls f. The name solution is the function you write. A name like "obj.method" calls the method with obj as this. An optional "this" sets this for the call, an optional "new": true calls it with new, and an optional "let" saves the result under a name.

The expected output has one entry for each call, in order: {"returns": value} or {"throws": "ErrorName"}. A function is written {"$function": true} and undefined is written {"$undefined": true}.

Function

collectArgs(steps: JsSteps) → JsStepResults

Examples

Example 1

steps = [{"let":"sum3","value":{"$js":"(a, b, c) => a + b + c"}},{"call":"solution","args":[{"$js":"sum3"}],"let":"c"},{"call":"c","args":[1],"let":"c1"},{"call":"c1","args":[2],"let":"c12"},{"call":"c12","args":[3]},{"call":"c","args":[1,2,3]},{"call":"c","args":[1,2],"let":"c2"},{"call":"c2","args":[3]}]return = [{"returns":{"$function":true}},{"returns":{"$function":true}},{"returns":{"$function":true}},{"returns":6},{"returns":6},{"returns":{"$function":true}},{"returns":6}]
  • The gathering function for sum3 (which declares 3 parameters) is a function: {"returns": {"$function": true}}.
  • c(1) has 1 of 3 arguments, so it returns a function. c1(2) has 2 of 3, so it returns a function again.
  • c12(3) reaches 3 arguments and returns 1 + 2 + 3 = 6. c(1, 2, 3) also returns 6.
  • c(1, 2) has 2 of 3 and returns a function, and c2(3) returns 6.

Example 2

steps = [{"let":"join3","value":{"$js":"(a, b, c) => [a, b, c].join('-')"}},{"call":"solution","args":[{"$js":"join3"}],"let":"c"},{"call":"c","args":["a"],"let":"ca"},{"call":"ca","args":["b","c"]},{"call":"ca","args":["x","y"]},{"call":"ca","args":["z"],"let":"caz"},{"call":"caz","args":["!"]}]return = [{"returns":{"$function":true}},{"returns":{"$function":true}},{"returns":"a-b-c"},{"returns":"a-x-y"},{"returns":{"$function":true}},{"returns":"a-z-!"}]
  • c('a') returns a function ca. ca('b', 'c') reaches 3 arguments: "a-b-c".
  • ca('x', 'y') starts again from 'a', not from 'b' and 'c': "a-x-y".
  • ca('z') has 2 of 3 and returns a function caz. caz('!') gives "a-z-!".

Example 3

steps = [{"let":"pack","value":{"$js":"function (a, b) { return [a, b, arguments.length]; }"}},{"call":"solution","args":[{"$js":"pack"}],"let":"c"},{"call":"c","args":[1,2,3,4]},{"call":"c","args":[1],"let":"c1"},{"call":"c1","args":[2,3]}]return = [{"returns":{"$function":true}},{"returns":[1,2,4]},{"returns":{"$function":true}},{"returns":[1,2,3]}]
  • pack declares 2 parameters and returns [a, b, number of arguments received].
  • c(1, 2, 3, 4) has 4 arguments, which is at least 2, so pack gets all 4: [1, 2, 4].
  • c(1) returns a function, and c1(2, 3) brings the total to 3: [1, 2, 3].

Constraints

  • fn declares 0 to 6 parameters before any default value or rest marker
  • Each test has 4 to 8 steps, and every call has 0 to 5 arguments

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Flatten a Multilevel Doubly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Recursive Task Worker with MemoizationCitadel · ONSITE INTERVIEWCitadel interview questions
  • Implement a Self-Balancing BST (AVL Tree)Microsoft · ONSITE INTERVIEWMicrosoft interview questions
  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • Task Scheduler with Prerequisites and Execution PathsBrex · PHONE SCREEN
  • Per-Client API Rate LimiterDocker · PHONE SCREEN
  • Read Across Sound TracksAirbnb · PHONE SCREENAirbnb interview questions
  • Streaming Median of Trade PricesXantium · PHONE SCREEN
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW

Interview reports that mention this question

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling Frontend, Mobile, Data: 18 Experiences (Part 12 of 12)

Rippling interview experiences

  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
Checking account…