how to push new key of array of object to new array in javascript code example
Example: javascript push object into array with variable key
//Normal Javascript
var key = "happyCount";
var obj = {};
obj[key] = someValueArray;
myArray.push(obj);
//OR
//If you're able to use ES6 and Babel, you can use this new feature:
{
[yourKeyVariable]: someValueArray,
}