I have created this enum:
export enum MyEnum {
VALUE1 = 'brown',
VALUE2 = 'green'
}
I would like to iterate over the enum for the purposes of building a select menu with the key being the value and the string being the label. But this code:
for (const key in Object.keys(MyEnum)) {
console.log('value is');
console.log((MyEnum as any)[key]);
}
produces an "undefined" when I try and look up an enum value by key. What's the proper way to get the enum value by its key?