Java Insert Into Array Javascript Iteration