+ 3
[Solved] Can I get a variables value to use it to bring an array's value.
I want to use my variable to bring an array's output. Like bellow: var arr = ["A", "B", "C"] var input = prompt("input"); var output = arr[(instead writing the number of element to get directly, I want here the users input) input] Please answer my question.
2 Antworten
+ 3
the input by user is stored in a variable called input.
so u would use arr [ input ]
if input is 0 it would mean:
arr [ 0 ]
which is equal to "A"
+ 3
Thanks a lot!
My code is working correctly now.