say I have an array like this:
const myArray = ['HP', 'QP', 'PS'];
And I'd like to have an object whose keys are myArray
's values like
{ HP: 0, QP: 0, PS: 0 }
Is there a way to do the following in one line:
const myObj = {};
myArray.forEach(item => myObj[item] = 0);