Command Palette

Search for a command to run...

Hectal
Phase 6: Rendering AI Output Safely
AI Frontend · Exercise 1 of 5Next
Intermediate

Show the Reply as Text

The button #show puts a model reply into #answer. The reply contains a tag with a harmless handler that adds 1 to window.bananas. Right now the page parses the reply as HTML and the handler runs.

Change the code so the reply is shown as text: #answer must contain the characters of the reply, and window.bananas must stay unset.

What Check tests

  1. Before the click #answer is empty
  2. After the click #answer contains the tag as visible text
  3. No element was created inside #answer
  4. The handler never ran

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.