I am trying to pass an array of objects in a onclick function inside a for loop. The scope of the array is inside the for loop only, So I cannot do like this. A sample of my cod