Let $f:\mathbb R \to \mathbb R$ has Intermediate value property. If f has local extremum at every point of $\mathbb R$, can we say f is constant? We know $$f(x)=\begin{cases}1 & x \in \Bbb{Q} \\ 0 & x \not \in \Bbb{Q}\end{cases}$$ has I.V.P and every point of $\mathbb R$ is local extremum but f is not constant. We know If f is continuous and have local extremum at every point then we can conclude f is constant if all extremum are maximum or minimum then proof is easy and is as follow:
If f is continuous and has a local maximum everywhere, then, let $a \in \mathbb R$. By continuity, $\{x:f(x)≤f(a)\}$ is closed, and by the hypothesis, $\{x:f(x)≤f(a)\}$ is open. The set $\{x:f(x)≤f(a)\}$ is nonempty, open and closed set of $\mathbb R$ so it is all of $\mathbb R$ by connectedness of $\mathbb R$. Therefore, for all $x$ and $y$ in $\mathbb R$, $f(b)≤f(a)$ and similarly $f(a)≤f(b)$.