Code Room
Code reviewMediumcr-g343
Subject SerializationLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this JavaScript that builds a price-count histogram and serializes it, expecting to read prices back later.

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 reviewjavascript
function histogram(prices) {  const h = {};  for (const p of prices) {       // p like 0.1, 0.2, 0.3    const key = p * 3;            // bucket width grouping    h[key] = (h[key] || 0) + 1;  }  return JSON.stringify(h);}
Run or narrate your approach, then ask the coach.