Two Pointer Algorithm Javascript Array Length