To create a numbered list in Svelte from an array of runners in JavaScript, you can use a combination of list rendering and string interpolation. Here's an example code block:
83 chars6 lines
In this example, we're looping through each runner in the runners
array using the #each
block. The second variable in the #each
statement, i
, gives us the index of the current item in the loop. We can then use this index to display a numbered list item with the format {i + 1}. {runner}
. The +1
is added to the index to start the list at 1 instead of 0.
gistlibby LogSnag