I am stuck on an exercise which is: Let $A$ be a dense subset of a metric space $X$. Suppose that every Cauchy sequence in $A$ converges to a point in $X$. Prove that $X$ is complete.
I have seen that similar questions have been answered here: Proving that $X$ is complete if $A\subset X$ is dense and every cauchy sequence in $A$ converges to a point in $X$. and here: Every Cauchy sequence in $A$ converges in $X$, where $A$ is dense. Show that $X$ is complete.
I am having trouble understanding this proof. I understand that we have to show that any Cauchy sequence $\{x_i\}$ in $X$ converges in $X$. The part I don't understand is why we pick $y_n \in A$ such that $d(x_n, y_n) < \frac{1}{n}$. Is this because we know that every Cauchy sequence in $A$ converges to a point in $X$?
Any help or hints would be appreciated.