Code Room
Code reviewMedium
Question
Review this JavaScript service that builds a dashboard of teams with their member counts.
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
async function teamsWithCounts(orgId) { const teams = await db.query("SELECT id, name FROM teams WHERE org_id = $1", [orgId]); const result = []; for (const t of teams) { const c = await db.query("SELECT COUNT(*) AS n FROM members WHERE team_id = $1", [t.id]); result.push({ ...t, members: c[0].n }); } return result;}Run or narrate your approach, then ask the coach.