Command Palette

Search for a command to run...

Hectal
Phase 3: Stop, Retry and Failure
AI Frontend · Exercise 1 of 5Next
Intermediate

Add a Stop Button

#ask starts a streamed answer into #answer. Make the button #stop work: when it is clicked while the answer is arriving, the request must be cancelled, the text that already arrived must stay, and #status must say Stopped.

When the answer finishes by itself, #status says Done. A Stop is not an error: do not write anything into #error.

What Check tests

  1. While the answer streams, #answer holds part of the sentence
  2. Clicking #stop sets #status to Stopped and leaves #error empty
  3. After the Stop, the text stays and no more text arrives
  4. Asking again without stopping still ends with Done

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.