Answer the question
In order to leave comments, you need to log in
How to add a variable to an array?
Hello!
There is a line:
var meth = "action";
st(meth);
function st(meth){
data.push({
'ecommerce': {
meth : { 'products': [product] }
}
});
}
Answer the question
In order to leave comments, you need to log in
var value = {
'ecommerce': {}
};
value.ecommerce[meth] = { 'products': [product] }
data.push(value);
var meth = "action", data = [];
function st(meth){
data.push({
'ecommerce': {
[meth]: { 'products': ["product"] }
}
});
}
st(meth);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question