I am not sure which is the x-intercept and which is the y-intercept, since you did not specify.
Suppose the x-intercept is 2 and the y-intercept is -1.
This means that the line passes through (2, 0) and (0, -1).
Using the slope formula, we have:
(y - 0) / (x - 2) =(-1 - 0) / (0 - 2)
y / (x - 2) = -1 / -2
y / (x - 2) = 1/2
y = (1/2)(x - 2)
y = (1/2)x - 1, which is the line we need.
Suppose the x-intercept is -1 and the y-intercept is 2 instead.
This means that the line passes through (-1, 0) and (0, 2).
Using the slope formula, we have:
(y - 2) / (x - 0) = (0 - 2) / (-1 - 0)
(y - 2) / x = -2 / -1
(y - 2) / x = 2
y - 2 = 2x
y = 2x + 2, which is the line we need.