I have 1 variable and 1 array. The array contains any number of numbers, from 0 to 10 - like such: 0,1,2,3,4,5 and so on.
My variable contains 1 number, let's say 4 - I want to use the variable to get the number at index 4 in the array, minus 1. So in the above examples, I would get 2.
How can I go about creating a variable with that number? I have tried:
var goBack = $(userBack2).index(place-1);
Where goBack is the variable I am creating, userBack2 is the array containing my numbers and place is my variable determining what index I need.
I know that the syntax is completely wrong, that index might not be correct to use here, but I simply cannot figure out how to do it. Do I need to use filter? if so, how?
alert(ar[variable - 1])?var goBack = userBack2[place-1];