bugger.
All challenges/TypeScripteasythe-first-key-that-isnt-a-key-v1
THE INVESTIGATION

The first key that is not a key

Consecutive duplicate events slip through only at the start.

TypeScript & RuntimeAbsenceNormalization

What’s going wrong

An event filter emits the value of the first item and then emits only when the current selected key differs from the last emitted key using strict equality. Stdin is an array of {"key":scalar,"value":scalar} objects; scalars are strings, finite numbers, booleans or null. Print the emitted values in order. Key types are significant: 1 and "1" differ. Only consecutive equal keys collapse, and emitted payload values do not participate in comparison. An empty stream prints [].

Read one JSON value from stdin and print the specified JSON result to stdout. No actual network or external package is used.

Expected behavior

Normalize stored comparison state from the first item onward instead of mixing a value with its selected key.

Reproduction

01 Duplicate selected key at startup
[{"key":"a","value":1},{"key":"a","value":2}]
[1]
02 Changing key control
[{"key":"a","value":1},{"key":"b","value":2}]
[1,2]
03 Empty stream
[]
[]

Before you begin

  • Build on missing tuple positions: initialize state explicitly and preserve falsey values as valid data.
  • TypeScript unions, arrays, objects and functions
  • Trace runtime behavior even when the program type-checks

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.