Command Palette

Search for a command to run...

Hectal
Phase 15: Interviews and Capstone
AI Frontend · Exercise 1 of 6Next
Beginner

Read Events Cut Across Packets

A stream arrives in four packets that ignore event boundaries (they are in the packets array). Each event is one line data: <text> followed by a blank line. Press #run and show the texts of all events, joined with one space, in #out. With these packets the answer is Hello Mitra.

Keep a buffer: add each packet to it, split it on the blank line (NL + NL), and keep the last piece, which may be an unfinished event, for the next packet.

What Check tests

  1. Before pressing, #out is empty
  2. After pressing, #out shows Hello Mitra
  3. The text data: never appears in #out

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.