DEV Community

Discussion on: How to use integers/strings in arrays as variables?

Collapse
 
kallmanation profile image
Nathan Kallman

You're not too far off in concept. I think calling it "creating" or "assigning" variables will just confuse you though.

It's more adding/removing/modifying values in a data structure (in this case, just an array).

I made a simple example for you to hopefully answer some of the more specific details you may be struggling with.

I'll note that this is not production level code. A few things (of many) to improve:

  1. Avoid global variables
  2. Avoid functions doing both app logic and DOM effects

Thread Thread
 
purplepotatobro profile image
PurplePotatoBro

I finished my project a few hours ago, thanks!