Let $g, h$ be continuous functions defined on some interval $J$ and suppose that $g(x) \neq 0$ for any $x \in J$. If $g(x)^2 = h(x)^2$ for all $x \in J$, show that either $g(x) = h(x)$ for all $x \in J$ or $g(x) = -h(x)$ for all $x \in J$.
I know that when I get a square root of something, then the result could be negative of positive. SO I was thinking in doing cases, but I am not really sure where should I add the Intermediate Value Theorem.
Also, $g(x)^2 - h(x)^2 = (g(x) + h(x))(g(x) - h(x))$. Could I make each of them $=0$, and I am done?