Both responses you have received provide correct answers. In fact, you don't need to go so far as to obtain elements of relatively prime orders; all you need to worry about are primes with the property that they divide $nm$, and the largest power of $p$ that divides $n$ is equal to the largest power of $p$ that divides $m$.
Lemma. Let $x$ and $y$ be commuting elements of a group $G$, and assume $x$ and $y$ are of finite orders $n$ and $m$, respectively. Suppose that for every prime $p$ that divides $nm$, the largest power of $p$ that divides $n$ is different from the largest power of $p$ that divides $m$. Then the order of $xy$ in $G$ is $\mathrm{lcm}(n,m)$.
Proof. Let $\ell=\mathrm{lcm}(n,m)$. It is easy to verify that $(xy)^{\ell}=1$, so we just need to show that $\ell$ is the smallest positive integer $k$ such that $(xy)^k=1$. Suppose that $(xy)^k = 1$, with $0\lt k\leq \ell$.
Since $(xy)^k = x^ky^k = 1$, then $x^k = y^{-k}$, and in particular $x^k$ has the same order as $y^k$. The order of $x^k$ is $n/\gcd(n,k)$, and the order of $y^k$ is $m/\gcd(m,k)$. Let $p$ be a prime that divides $\ell$, and let $a=\mathrm{ord}_p(n)$, $b=\mathrm{ord}_p(m)$, and $c=\mathrm{ord}_p(k)$. Assume $b\lt a$. If $c\lt a$, then $\mathrm{ord}_p(n/\gcd(n,k)) = a-c$, and $\mathrm{ord}_p(m/\gcd(m,k))=\max(0,b-c)\lt a-c$, which is impossible. Thus, $c=a$. A symmetric argument shows that if $a\lt b$, then $c=b$. That is, for all primes $p$ that divide $\ell$, we have $\mathrm{ord}_p(k) = \max(\mathrm{ord}_p(n),\mathrm{ord}_p(n)) = \mathrm{ord}_p(\ell)$. Hence $k=\ell$. QED
So now assume that $a$ is an element of order $n$ in an abelian group, and let $b$ be an element of order $m$. Let $p_1,\ldots,p_k$ be the primes that divide $nm$ and for which the $p$-order of $p_i$ in $m$ and in $n$ are equal. Then
$$\mathrm{lcm}(n,m) = \mathrm{lcm}\left(n, \frac{m}{p_1\cdots p_k}\right).$$
Since $m/(p_1\cdots p_k)$ is the order of $b^{p_1\cdots p_k}$, then it follows from the lemma that $ab^{p_1\cdots p_k}$ has order $\mathrm{lcm}(n,m)$, as desired.