Detect a Real Array
Updated
Problem statement
Write isRealArray(value). It returns true when value is a real JavaScript array, and false for every other value. Do not call Array.isArray (the tests cannot check this; the point is to build the check yourself).
Rules for this exercise:
- All of these are real arrays: an empty array, a sparse array, an array with extra properties, a frozen array, an instance of a class that extends
Array,Array.prototypeitself, and aProxythat wraps an array. - None of these are real arrays: strings, numbers,
null,undefined, objects with alength, theargumentsobject, typed arrays, buffers, sets, functions, aProxyaround anything else, and objects that only look like arrays, such as an object whose prototype isArray.prototype, an object withconstructor: Arrayor an object with a fakeSymbol.toStringTagof"Array". - Arrays that carry their own
Symbol.toStringTagproperty are not tested. - Arrays made in another realm (a separate JavaScript environment, like a frame) are not tested, because the judge cannot make one. A good answer still counts them.
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
isRealArray(steps: JsSteps) → JsStepResultsExamples
Example 1
steps = [{"call":"solution","args":[{"$js":"[1, [2], 3]"}]},{"call":"solution","args":[{"$js":"[]"}]},{"call":"solution","args":["abc"]},{"call":"solution","args":[7]},{"call":"solution","args":[null]},{"call":"solution","args":[{"$js":"undefined"}]}]return = [{"returns":true},{"returns":true},{"returns":false},{"returns":false},{"returns":false},{"returns":false}][1, [2], 3]is an array:true.[]is an array:true.- The string
"abc", the number 7,nullandundefinedare not arrays:falsefour times.
Example 2
steps = [{"call":"solution","args":[{"$js":"({ 0: 'a', 1: 'b', length: 2 })"}]},{"call":"solution","args":[{"$js":"(function () { return arguments; })(1, 2)"}]},{"call":"solution","args":[{"$js":"new Int8Array(2)"}]},{"call":"solution","args":[{"$js":"new Set([1])"}]},{"call":"solution","args":[{"$js":"function () {}"}]}]return = [{"returns":false},{"returns":false},{"returns":false},{"returns":false},{"returns":false}]- An object with a
lengthof 2 and keys 0 and 1 looks like an array but is a plain object:false. - The
argumentsobject, anInt8Array, aSetand a function are not arrays:falseeach.
Example 3
steps = [{"call":"solution","args":[{"$js":"new Array(3)"}]},{"call":"solution","args":[{"$js":"new (class Stack extends Array {})()"}]},{"call":"solution","args":[{"$js":"Array.prototype"}]},{"call":"solution","args":[{"$js":"new Proxy([], {})"}]}]return = [{"returns":true},{"returns":true},{"returns":true},{"returns":true}]new Array(3)has three empty slots but is an array:true.- An instance of
class Stack extends Array,Array.prototypeand aProxyaround an empty array are arrays:trueeach.
Constraints
- value is any JavaScript value that the test builds with an expression
- Each test has 3 to 6 steps, and every call has exactly 1 argument
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 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)