-1

I know this question has been asked before but I am really confused as how to apply it in my particular instance.

I am trying to use a variable instead of productId1 in my array parameter, but I am not sure on how to do

var obj = {};
obj.push(something)

with this case.

Any help would be appreciated.

Code:

$BV.ui( 'rr', 'inline_ratings', {
             productIds : {
                  'productId1': { 
                  url : '/Dummy URL here'
                }
             },
Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
alyn000r
  • 546
  • 2
  • 8
  • 19

1 Answers1

1

You can't use variable keys in object literals. You have to create the object first and then use obj[key] syntax to fill in the object, e.g:

var obj = { };
obj[productId1] = { url: '/Dummy UR here' }
$BV.ui('rr', 'inline_ratings', obj);
Alnitak
  • 334,560
  • 70
  • 407
  • 495