How would you update one nested object without changing its siblings?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
Immutability requires copying the changed path, not only the top-level object. Stable unchanged references can also help avoid unnecessary work.
Rename passenger 2 in an array while preserving every other passenger and nested field.
A practical way to learn it
Rename one passenger with map, then update only their address pin. Check that the other passenger remains identical.
Open JavaScript playgroundThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would use a functional state update, map the array and copy only the matching item. For a nested address change I would copy the parent object and that address before changing the field. I would preserve unrelated properties with spreads at the correct level and avoid mutating the original object. A shallow copy does not protect deeper values by itself. For complex updates I would consider a reducer or an immutability helper, while still testing the expected before and after data.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Spreading the entire parent into a nested address.
- Comparing an object directly with an ID.
Now go one level deeper
- What happens if the ID is missing?
- When would a reducer improve clarity?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.