We can write the function in slope-intercept form (y + mx + b). Since we have the slope, we can solve for the y-intercept.
y = -2x + b
4 = -2(0) + b
4 = b
Input the data we have now.
y = -2x + 4
Since we are dealing with a function switch out the y for f(x)
f(x) = -2x + 4
Best of Luck!