All problems

A Blank Edit Clears the Previous Pottery Caption

Level 2 · node · Data · Blank edits in partial caption replacement

Scenario

A fictional pottery archive receives caption edits in chronological order. A whitespace-only edit means there is nothing to update, but sometimes a previously saved caption disappears.

Requirements

Return the most recent nonblank caption, without leading or trailing whitespace. Return an empty string if no such caption exists.

Acceptance criteria

  • Trim a single nonblank caption.
  • A final blank edit does not erase the preceding caption.
  • Apply a new caption after an intermediate blank edit.
  • Return an empty string if no valid caption exists.