Code Room
Code reviewHardcr-g254
Subject SecurityLevel Senior–Staff~30 minCommon in Security interviewsIndustries Software development

Question

Review this JS deep-merge used to apply user-supplied config over defaults.

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 deepMerge(target, source) {  for (const key in source) {    if (typeof source[key] === 'object' && source[key] !== null) {      target[key] = target[key] || {};      deepMerge(target[key], source[key]);    } else {      target[key] = source[key];    }  }  return target;}// usage: deepMerge(defaults, JSON.parse(req.body.config))
Run or narrate your approach, then ask the coach.