I have a set which needs to be converted into an object with the set's unique values as the object keys and an empty string as each element's value in the object.
Here is the set I'm working with:
const uom = new Set(['inches', 'centimeters', 'yards', 'meters']);
I've tried this:
const uomObj = {...[...uom]};
console.log(uomObj);
Which yields this:
Object {
"0": "inches",
"1": "centimeters",
"2": "yards",
"3": "meters",
}
but that does not match the desired result of:
Object {
"inches": "",
"centimeters": "",
"yards": "",
"meters": "",
}
Can this be achieved with an ES6 approach? If so, how?