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
- While the answer streams,
#answerholds part of the sentence - Clicking
#stopsets#statustoStoppedand leaves#errorempty - After the Stop, the text stays and no more text arrives
- 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.