Svelte · Junior · Question 18 of 76
How do you render a list?
{#each todos as todo (todo.id)}
<li>{todo.text}</li>
{:else}
<li>Nothing to do</li>
{/each}- ✓Correct answer: With
{#each items as item (key)};{:else}renders when the list is empty - 2With
items.map()inside the markup - 3With a
forattribute on<li>
Explanation
The expression in parentheses is the key. It helps Svelte insert and remove items precisely instead of updating existing DOM.