To generate a random name in Svelte, you can use a list of names and a random number generator. Here's an implementation using JavaScript and Svelte:
311 chars12 lines
In this implementation, the generateName
function picks a random name from the names
array and returns it. We can call it in response to a button click, and display the generated name in a paragraph element.
Of course, you can customize the list of names to suit your needs, or even load it from an external file or API.
gistlibby LogSnag