Intermediate value theorem states that if a function, f, with an interval, [a, b], as its domain, takes values f(a) and f(b) at each end of the interval, then it also takes any value between f(a) and f(b) at some point within the interval
For intermediate value theorem to hold true, the function must be continuous or the definition of IVT assumes the function to be continuous.
So the correct definition is as follows:
intermediate value theorem states that if a continuous function, f, with an interval, [a, b], as its domain, takes values f(a) and f(b) at each end of the interval, then it also takes any value between f(a) and f(b) at some point within the interval.
If we take a function which is discontinuous in an interval and try to apply this between end points discontinuity, we will understand why it is necessary to have a continuous function.