Java While Loop Through Array Javascript Append