array object assign new key and value 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);