I'm trying to access different variables depending on user input. To simplify, let's say I have three variables, x1 = "variable 1"
, x2 = "variable2"
and x3 = "variable3"
. I want to be able to call a different variable, depending on another variable, y
. Let's say y=2
, that means I want to get x2.
I tried something like console.log(x[y])
, but that doesn't seem to work. I didn't find anything on this topic anywhere, so I don't know if it's possible or not, or if that's even how you would solve this problem.
For those who are interested, I'm trying to access different Discord.RichEmbed()
s depending on the variable, and I don't think I can store those in an array. If that is somehow possible, please let me know.
If I forgot to explain something let me know and I'll add it or answer any questions you might have
Thanks in advance ^^
EDIT: It would also work if y="x2"
and if I could then somehow get the contents of x2 that way.