Answers for "assign an element value as key in array of objects"

0

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);
Posted by: Guest on August-02-2020

Code answers related to "assign an element value as key in array of objects"

Code answers related to "Javascript"

Browse Popular Code Answers by Language