Use an {#each}…{/each}
block to iterate over an array in a template.
Use an {#if}…{/if}
block to conditionally render HTML.
Use {:else}
and {:else if …}
directives to add more conditions.
<script>
import Todo from './Todo.svelte';
let todos = [
{ task: "Mow lawn", completed: false },
{ task: "Walk dog", completed: false },
{ task: "Read newspaper", completed: false },
];
</script>
{#each todos as todo}
<Todo {...todo} />
{/each}
{#if todos.length === 0}
<p>All done!</p>
{:else if todos.length === 1}
<p>Almost there!</p>
{:else}
<p>Keep going!</p>
{/if}