I have an object comments:
let comments = {"id1": ..., "id2: ..., ...};
I then have an array commentsSortedByDate:
let commentsSortedByDate = ["id2", "id1", ...];
I would like to iterate over these comments. This is what I've tried:
{#each commentsSortedByDate as commentId}
<script> let comment = comments[commentId]; </script>
<div class="comment" class:new={comment.isNew}> ... </div>
{/each}
This does not work. How can I define this comment variable in the loop so that I can access it multiple times without having to type comments[commentId] each time?