Looking to construct an object consisting of empty arrays using values as keys.
const CATEGORIES = ['apple', 'banana', 'orange']
generateCategoryObject() === { apple: [], banana: [], orange: []}
function generateCategoryObject() {
const categoryObj = {}
for (const fruit of CATEGORIES) {
categoryObj[fruit] = [];
}
return categoryObj;
}
Hoping to enhance my understanding of ES6. Any suggestions on a concise solution for this?