I have a base array of 6 different words that represent game elements. Just wondering how I would multiply the number of instances of each word within the array.
var gameItem = [cattle, wood, stone, metal, grain, craft];
That is, say I want 10 instances of each word to be added to the array, how would I do that? Order isn’t important as it’ll be shuffled.
Don’t forget that your array doesn’t work unless you define each of those variable. But as I understand, those are words, not vars. So the right array declaration is:
To repeat that array 10 times, you can use a for loop and the array method
concat().I don’t know what is your idea for this, but, if you want to store a quantity of elements of those kinds, like, player has 1 cattle, 12 wood, 20 stone, etc …
You probably should have a better data structure, like this:
So by doing
gameItem.wood, you get the result> 12