It seems like my title might be a bit confusing, but oh well.
I'm currently working on developing a game and I have several arrays named things like ItemsInG5Array
, ItemsInB2Array
. These names correspond to different nodes on the map. What I'm aiming to achieve is a function that can provide a list of items in a specific node where the player is located.
function options(location)
locationPickups: while(true) {
pick = prompt("There are few items laying around.\n" + itemsInG6Array + "\nWould you like to pick something up?");
...
In this case, location
represents the name of the node. Is there a simple way I can make ItemsInG6Array
more dynamic, allowing it to change based on the value of the location
variable? Perhaps using a syntax like ItemsIn(location)Array
.