Code Room
Code reviewHardcr-g450
Subject SecurityLevel Senior–Staff~24 minCommon in Security interviewsIndustries Software development, Technology

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.

Talk through your review
Code to reviewjs
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.