Get every variable loop value in array - Javascript : Can somebody please help me out how to get every variable of loop into an array and call all the variables in some other variable.

I am very new to array. I don't have any idea how to solve this.

Suppose I have an Array[]

and the variable in an array is i, so i1, i2, i3 ....... in 
n is the number of times loop will run.
So
for (i=1; i<=n, i++) {
i need an array called here.
there will be some code play here
There will be some value returned after the code it could be text or no.
}
then i want to assign all the values of array into a variable with comma seperated

var k = array{}  i.e k = "i1,i2,i3,......in"

I try to find on google but not able to find any solution.

Please Help me out. it's urgent. This example is a reference for what I want to achieve actually.

