javascript assign array value to object key code example
Example: assign an element value as key in array of objects
var keys = ['HP', 'QP', 'PS'],
object = Object.assign(...keys.map(key => ({ [key]: 0 })));
console.log(object);
var keys = ['HP', 'QP', 'PS'],
object = Object.assign(...keys.map(key => ({ [key]: 0 })));
console.log(object);