Looping through arrays (lists)
In Svelte you can loop through arrays
{#each [name array] [item-in-array]}
<!-- Code here ->
{/each}
---
<script>
let list = ['apple', 'banana', 'cherry'];
</script>
<h2>This is a looped component</h2>
<ul>
{#each list as item}
<li>{item}</li>
{/each}
</ul>{#each [name array] [item-in-array]}
<!-- Code here ->
{:else}
<!-- Code here ->
{/each}Last updated