dynamic array in javascript example with for loop