I have the following code:
pub.call_response = function() {
return {
units: [
{
test_attributes: {
}
}
]
};
};
I have a set of variables that I need to use for the keys/values in test_attributes as follows:
var key1 = something;
var key2 = something;
var value1 = something;
var value2 = something;
pub.call_response = function() {
return {
units: [
{
test_attributes: {
key1: value1,
key2: value2
}
}
]
};
};
Obviously, this does not work. Does anyone have any ideas on how to do something like this? Using jQuery is acceptable.
Thanks!
You should do
var key1 = something;
var key2 = something;
var value1 = something;
var value2 = something;
var attributes = {};
attributes[key1] = value1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With