All problems

Numeric String Counts Concatenate in a Room Report

Level 2 · node · Correctness · Implicit string concatenation corrupts a count aggregate

Scenario

A fictional facility counts entries in individual rooms and generates reports. Depending on the counter device, recorded counts are integers or numeric strings. Integer-only reports are correct, but mixed or string-based counts are concatenated instead of numerically added. Inspect the repository, aggregation service, and controller.

Requirements

Sum all counts for a room numerically and return an integer total. Counts are integers or integer-formatted strings. Exclude other rooms, return zero total and zero entries for an empty room, and leave stored records unchanged. Do not add external packages.

Acceptance criteria

  • Counts for the same room are summed.
  • A zero count does not alter the total.
  • A numeric string count is added as a number.
  • Multiple numeric strings are summed, not concatenated.
  • Records from other rooms are excluded.
  • Reading does not modify stored count records.