Code Room
Code reviewHard
Question
Review this Node settings updater that applies a client-supplied dot-path patch.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
function applyPatch(target, patch) { for (const { path, value } of patch) { const keys = path.split('.'); let obj = target; for (let i = 0; i < keys.length - 1; i++) { const k = keys[i]; if (!(k in obj)) obj[k] = {}; obj = obj[k]; } obj[keys[keys.length - 1]] = value; } return target;} app.patch('/settings', (req, res) => { applyPatch(currentSettings, req.body.ops); res.json(currentSettings);});Run or narrate your approach, then ask the coach.