Closed
Description
I have one situation here :-
Below is my enum:-
export const ColorCodes = Enum({
ES_IN_1: 'RED',
ES_IN_2: 'YELLOW',
});
Now i get a string code dynamically from server :- 'ES_IN_1' or 'ES_IN_2' .
I need to compare this string code with enum and need to implement custom code. something like this:-
const serverCode = 'ES_IN_1';
if(serverCode == ColorCodes.ES_IN_1.toString()){
...... custom code.
}else if(serverCode == ColorCodes.ES_IN_2.toString()){
....... custom code.
}
The problem is how would i get key of this ColorCodes.ES_IN_1 'which is ES_IN_1'.
I dont see something toString() or getKey() here which could resolve this issue.
Thanks
Metadata
Metadata
Assignees
Labels
No labels