Two Pointer Algorithm Javascript Interview Question