I have a variable type coming from an external react component called type.
I need to run certain logic according to type.
So if type = foo
i want to run a command x= user.foo.id
while if it is boo
i want to run x=user.boo.id
I was thinking x=user.${type}.id
but that is not working.
What is the best way of doing this without having to rewrite the whole code with an if statemenet for each type?
Asked
Active
Viewed 24 times
1

Prateek Thapa
- 4,829
- 1
- 9
- 23

Mohamed Daher
- 609
- 1
- 10
- 23