views:

44

answers:

1

hi

so i am working with a json variable like this:

opponentInvData.item1

it contains items 1 through 6

i need to access the different items dynamically and set them to null. itemNum is the specific item i need to access. im trying to use the eval function

var itemNum = 2;
eval(opponentInvData.item + itemNum + ' = ""');

needless to say, it's not working, any ideas?

+6  A: 
opponentInvData['item1'] = "my item"

is the same as

opponentInvData.item1 = "my item"
Nikita Rybak