1

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?

Prateek Thapa
  • 4,366
  • 1
  • 8
  • 20
Mohamed Daher
  • 417
  • 7
  • 14

0 Answers0