He wants to set a variable to the index of the 'referenced' integer inside the array variable.
array: 3, 5, 6, 2, 7, 1, 8
referenced integer: 7
var x = 4
Correct me if I'm wrong, it is a bit vague mate :)
Anyway, if every integer occurs only once inside the array, you could just loop through the array, increase an integer i by 1 every iteration and check if array[i] is the reference integer. If it is, end the loop and i will be the index inside the array.
If you want to store your [gen], you'll need to store it the moment you fill that slot. It's either that or array iteration.
For future reference: "number string" = variable used to specify the index of the array slot. |