In function notation (f(x)=mx+b) m represents the slope and b represents the y-intercept.
In a straight horizontal line the slope is always 0. This cancels out the 'x' factor so you get f(x)=b.
To find b you simply look at where the line crosses the y-axis. in this case it crosses at 2.
When you plug in the y-intercept you get f(x)=2