I was getting over EVT whics states that if a real-valued function $f$ is continuous on the closed interval $[a,b]$ then $f$ must attain a maximum and a minimum, each at least once. Then there is one consequence which states following: If $f:[a,b]\rightarrow\mathbb{R}$ is continuous $\implies$ $f([a,b])=[f(x_{max}),f(x_{min})]$. Also there is some theorem which states that if $f$ is monotonic, then $\Longleftarrow$ holds.
My question is, why doesn't $\Longleftarrow$ hold if $f$ is not monotonic?
I would be very grateful if someone would explain this to me.
Take $$[a,b]=[0,4\pi]$$
$$f(x)=\sin(x)\;\; if \;\; x\ne \frac{\pi}{4}$$ $$f(\frac{\pi}{4})=\frac 12$$ $f$ is not continuous at $[a,b]$.
$f$ is not monotonic.
$$f([a,b])=[-1,1]=[f(\frac{3\pi}{2}),f(\frac{\pi}{2})]=[\min f,\max f]$$