Pop Element From Array Javascript Iteration