FastPrepFix the Receiver and First Arguments of a Function
Problems/Fix the Receiver and First Arguments of a Function

Fix the Receiver and First Arguments of a Function

Rippling logoRippling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two reports mention this topic. One comes from an SDE-1 frontend first round, which asked for it to be written by hand. The other comes from a senior frontend technical round, where it sits beside currying. Neither gives a signature or says what happens with new, with a target that is not a function, or when the wrapper is wrapped again.

Every rule here is our choice. The wrapper runs the target with the fixed receiver and the preset arguments first, then the later ones, and passes the result back. With new, the receiver is ignored and the object is an instance of the target. A target that is not a function gives a TypeError. Wrapping a wrapper keeps the first receiver and adds the preset arguments in order. The name and length of the wrapper, and symbol-valued receivers, are not tested. The step format, the tests and the examples are ours too.

This version calls the wrapper and checks what comes back. It cannot read your code, so the explanation side is in the editorial.

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

Add a method presetBind(receiver, ...first) to Function.prototype, so every function can call it. It returns a new function. Do not use the built-in bind (the tests cannot check this; the point is to build it yourself).

Let target be the function that presetBind was called on. When the new function is called with later arguments:

  • Called normally: run target with this set to receiver and with the arguments first followed by later, and return its result. The this of the new call is ignored.
  • Called with new: run target as a constructor with the arguments first followed by later, and give back what new target(...) gives back. receiver is ignored. The object it makes must still be an instance of target.

Rules for this exercise:

  • If presetBind is called on something that is not a function, throw a TypeError.
  • A function made by presetBind can call presetBind again. The first receiver stays, and the new preset arguments go after the earlier ones.
  • Each call to presetBind returns a separate function. The name and length of the new function are not tested.
  • An arrow function can be wrapped and called normally. Calling the wrapper with new then throws a TypeError, as it does for the arrow function.

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. A name like "add.presetBind" calls the method presetBind that you write, with add 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}. A plain object result is written as JSON, such as {"sum": 7}. An object made by a constructor is written {"$instance": "Pair", "fields": {...}}: the constructor's name and the object's own fields. Object results are compared by that name and those fields.

Function

presetBind(steps: JsSteps) → JsStepResults

Examples

Example 1

steps = [{"let":"obj","value":{"x":10}},{"let":"add","value":{"$js":"function (a, b) { return this.x + a + b; }"}},{"call":"add.presetBind","args":[{"$js":"obj"},1],"let":"bound"},{"call":"bound","args":[2]},{"call":"bound","args":[5],"this":{"x":100}}]return = [{"returns":{"$function":true}},{"returns":13},{"returns":16}]
  • add returns this.x + a + b. add.presetBind(obj, 1) returns a function bound.
  • bound(2) runs add with this = obj (where x is 10) and the arguments 1, 2: 10 + 1 + 2 = 13.
  • The next call passes its own this with x = 100, but that is ignored. bound(5) gives 10 + 1 + 5 = 16.

Example 2

steps = [{"let":"Pair","value":{"$js":"function Pair(left, right) { this.left = left; this.right = right; }"}},{"call":"Pair.presetBind","args":[null,"L"],"let":"P"},{"call":"P","args":["R"],"new":true,"let":"p"},{"let":"isPair","value":{"$js":"(v) => v instanceof Pair"}},{"call":"isPair","args":[{"$js":"p"}]}]return = [{"returns":{"$function":true}},{"returns":{"$instance":"Pair","fields":{"left":"L","right":"R"}}},{"returns":true}]
  • Pair stores its two arguments as left and right. Pair.presetBind(null, 'L') returns a function P.
  • new P('R') runs Pair as a constructor with the arguments 'L' and 'R'. The result is a Pair with left = "L" and right = "R".
  • The check p instanceof Pair is true.

Example 3

steps = [{"let":"holder","value":{"$js":"{ presetBind: Function.prototype.presetBind }"}},{"call":"holder.presetBind","args":[null]}]return = [{"throws":"TypeError"}]
  • holder is a plain object that has the method copied onto it. holder.presetBind(null) runs it with this = holder, which is not a function.
  • So it throws a TypeError: {"throws": "TypeError"}.

Constraints

  • receiver is an object, null or a function value
  • Each test has 2 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

  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP 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
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Top K Pins with Insert and QueryPinterest · PHONE SCREENPinterest interview questions

Interview reports that mention this question

  • Rippling Frontend, Mobile, Data: 18 Experiences (Part 12 of 12)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • 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…