Show that there exists a real function $f$ such that $x\to a, |f(x)|\to |L|$ but the limit of $f(x)$ does not exist. Show that there exists a real function $f$ such that $x\to a, |f(x)|\to |L|$ but the limit of $f(x)$ does not exist.
Just before this problem I was asked to prove the theorem:
If $L=\lim_{x\to a}f(x)$ exists, then $|f(x)|\to|L|$ as $x\to a$.
I was able to prove that just fine which is causing the confusion here. I was under the impression that in order to have
$\lim_{x\to a}f(x)=L, f(x)$ must approach L whenever $x$ approaches $a$. Based on that, how do we create an example where the limit does not exist?

The classic Sign Function is also Okay:
$$f(x) =\left\{\begin{matrix}
1 & x>0 \\ 
 0 & x =0 \\
-1 & x<0
\end{matrix}\right..$$
$\lim_{x \to 0} f(x)$ does not exist, but $\lim_{x \to 0} | f(x) | = 1.$
