Two Pointer Algorithm Javascript Foreach Continue C