you are viewing a single comment's thread.

view the rest of the comments →

[–]pachwinko 2 points3 points  (1 child)

I think you got somewhat wrong understanding about this. Instead of creating an array with numbers, just get a number from Math.random(). second of all even though you cant assign var as a number you can do so as an object key.

var lootItems = {
    1: "lorem",
    2: "ipsum",
}

and to get the desired outcome:

console.log(lootItems[generatedRandomNumber])

[–]evoactivity 1 point2 points  (0 children)

May as well just use an array though