index.tsx471 chars21 lines
In the code above, we first define a list of sprinters with their names and times. We then sort this list by their time in ascending order.
To display the sprinters in a numbered list format, we use the each
block in Svelte to iterate through the sorted list of sprinters. The i
variable represents the current index of the sprinter in the list, which we add to 1 to create a numbering scheme that begins with 1. We then display the name of the sprinter and their time in seconds using template literals.
Finally, we wrap the entire list in an ordered list (<ol>
) tag, which automatically generates the numbering for each item using the li
tags created in the each
block.
gistlibby LogSnag