Command Palette

Search for a command to run...

Hectal
Phase 8: The DOM
JavaScript · Exercise 3 of 5 PreviousNext
Intermediate

Render a list safely

Write a function renderFruits(names) that replaces everything in #list with one <li> per name, in order.

Names come from users, so they must appear exactly as typed: <b>Kiwi</b> must show the angle brackets, not bold text.

Calling it twice must not duplicate items. The starter already calls renderFruits(fruits) once.

What Check tests

  1. On load the list shows the three fruits in order
  2. <b>Kiwi</b> is shown as text, not as a bold element
  3. Calling renderFruits with new names replaces the list
  4. Calling it twice doesn't duplicate items
  5. An empty array leaves an empty 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.