Two Pointer Algorithm Javascript Array Find Index