Two Sum Algorithm Javascript Substring Until Character