Two Pointer Algorithm Javascript Substring Last 4