DND Name Generator

This project was super fun and very doable for someone at my level. Took me 2-3 hours. Open to feedback and fun feature ideas!

Hi @beta5125905023 !
Nice job! Would you like a challenge?

What about this:

  1. Instead of inputs being an array, make it an object.
  2. Avoid creating all those const variables with strings values. Use the names of the variables as properties of inputs and use the literal strings as their values inside the object.
  3. In order to get a random name, you need to pass an array to getRandomItem(). Check the method Object.keys(), so you can use its returned value when using it like: Object.keys(inputs). MDN.
  4. With the array of keys, you can get a random key and use it to access inputs[randomKey]. Now you can set your name variable and your program doesn’t create a lot of variables.

If you try it, I’m here to help :wink:

1 Like