According to Bolzano's theorem (also known as the intermediate value theorem), if a continuous function defined on the interval [a;b] takes two different values, then it takes any value between them.
It immediately follows from this theorem that this function takes the value 2 on the intervals [-2;0], [4;6] and [6;7], that is, three times.
Answer: f(x)=2 at least three times.
The screenshot shows an example of a continuous function that takes these values.