I am trying to build this function that sets up my object for me
var schema = function(tableName, data) {
return dataSet = {
tableName: {
1: data
}
};
};
var dataSet = schema("messages", data);
But when I execute this it returns tableName as a string, not using the variable that I pass through the function?
Is it possible to use the variable that I pass into my function as a name so that I get it returned like this:
{
"message": {
"1": {
"username": "Simon",
"message": "First message"
}
}
}
Instead of this:
{
"tableName": {
"1": {
"username": "Simon",
"message": "First message"
}
}
}