Command Palette

Search for a command to run...

Hectal
Phase 6: Rendering AI Output Safely
AI Frontend · Exercise 5 of 5 Previous
Advanced

Build the Source List

Two buttons feed a list of source parts to renderSources(parts). #with sends five parts and #without sends none.

Draw an ordered list #sources with one li per distinct address (keep the first, number by first appearance). Use the part's title as the text. Make it a link only if the address is http: or https:. When there are no parts, show #empty with the text This answer is not from the shop's help pages. and no list.

What Check tests

  1. With sources, #sources has 4 items (the duplicate is dropped)
  2. The items are in order of first appearance
  3. The javascript: source is listed without a link
  4. The safe sources are links
  5. With no sources, #empty has the note and there is no list

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.