Code Room
Code reviewMedium
Question
Review this TypeScript payment-charge function.
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 charge(req: ChargeRequest, logger: Logger) { logger.info('charge request', { user: req.userId, card: req.cardNumber, cvv: req.cvv, amount: req.amount, }); const result = await gateway.charge(req); if (!result.ok) { logger.error(`charge failed for ${req.cardNumber}: ${JSON.stringify(req)}`); } return result;}Run or narrate your approach, then ask the coach.