Let $\varphi:G\to G'$ be a surjective homomorphism. Prove that if $G$ is cyclic, then $G'$ is cyclic, and if $G$ is abelian, then $G'$ is abelian. I am trying to solve the below Exercise 5.1 in Artin's Algebra.

Let $\varphi: G \to G'$ be a surjective homomorphism. Prove that if $G$ is cyclic, then $G'$ is cyclic, and if $G$ is abelian, then $G'$ is abelian.

Here is my attempt.

Let $G = \langle x \rangle$. I claim that $G' = \langle \varphi(x) \rangle$. Given $y \in G'$, by surjectivity of $\varphi$, there exists $a \in G$ such that $\varphi(a) = y$. As $G$ is cyclic, we have $a = x^m$ for some $m \in \mathbb{N}$. So we have
\begin{align*}
\varphi(a) = \varphi\left(x^m\right) = \varphi\left(x\right)^m = y,
\end{align*}
so $y \in \langle \varphi(x) \rangle$, so $G' \subset \langle \varphi(x) \rangle$. By definition, $\langle \varphi(x) \rangle \subset G'$, so $G' = \langle \varphi(x) \rangle$, so $G'$ is cyclic.
Suppose now that $G$ is abelian. Given $a,b \in G'$, by surjectivity of $\varphi$, there exist $x,y \in G$ such that $\varphi(x) = a$ and $\varphi(y) = b$. Then, we have
\begin{align*}
\varphi(xy) = \varphi(x) \varphi(y) = ab,
\end{align*}
but
\begin{align*}
\varphi(xy) = \varphi(yx) = \varphi(y) \varphi(x) = ba,
\end{align*}
so $ab = ba$, and $G'$ is abelian.

How does this look?

It looks fine to me. Well done!
I would write the last few calculations in one go, though, like this:
$$\begin{align}
ab &= \varphi(x) \varphi(y)\\
&=\varphi(xy)\\
&=\varphi(yx)\\
&=\varphi(y)\varphi(x)\\
&=ba.
\end{align}$$
