<script> const sections = { "Title 1": "paragraph", "Title 2": "paragraph", "Title 3": "paragraph", "Title 4": "paragraph", "Title 5": "paragraph" } // Object.entries() converts an Object into an array of arrays, // each sub array first index is the a key and the second index is a value // Object.entries({key: value, key:value}) => [[key, value], [key,value]] </script> {#each Object.entries(sections) as [title, paragraph]} <h1>{title}</h1> <p>{paragraph}</p> {/each}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter