While Loop Array Javascript Iteration