How to combine index variable into a string?

I want to update a collection like this,

Books.update({_id:bookid},{$set:{‘string.index.weight’:weight}}); / / index is a chaning variable

but it didn’t work, then I try this,

var string=‘bookitems.’+index+’.weight’; / / index is a chaning variable
Books.update({_id:bookid},{$set:{string:weight}});

it is still not work.

var s = {};
s['bookitems.'+index+'.weight'] = weight;
Books.update({_id:bookid},{$set:s});

@Steve is spot on.

Have a read of this blog post.
Third tip down: ‘Variables as keys’.