Suppose $G$ is a group of order $2p$, where $p$ is a prime. Show that there exists an onto homomorphism $G \rightarrow H$, where $H$ is a group of order $2$.
Here is my attempt:
By Cauchy's Theorem, there exists $a \in G$ with order $p$, so $\langle a \rangle \leq G$. Write $H = \langle h \rangle = \{e_H, h\}$ and define $f: G \mapsto H$ by \begin{align*} f(g) = \begin{cases} e_H & \text{if $g \in \langle a \rangle$} \\ h & \text{otherwise} \end{cases} \end{align*}
Is this correct? I am able to show that $f$ behaves like a homomorphism for all cases except when $g_1, g_2 \in G - \langle a \rangle$. That is, I want to show that $g_1g_2 \in \langle a \rangle$ in order for this to be a homomorphism, but I don't know how. Perhaps this is not even the right answer though...