SAT Math Algebra Problem - help!

These problems really trip me up. I usually extend out to the problem, but then I’m unsure on how to group them. Please help? Thank You so much!

If a2+xa+18=(a+y)(a+3) for all values of a and for constants x and y, what is x?

Well, we have:

a^2 + xa + 18 = (a + y) (a + 3)

Let’s FOIL the right side so we have both sides in the same format

a^2 + xa + 18 = a^2 + ya + 3a + 3y

The 2nd and 3rd terms of the right hand side can be combined

So we get

a^2 + xa + 18 = a^2 + (3+y)a + 3y

We can cancel a^2 on both sides.

xa + 18 = (3+y)a + 3y

On the left hand side, we have xa + 18. a is a variable, 18 is a constant.

On the right hand side (3+y)a is a variable, 3y is a constant (it says in the problem y is a constant, so 3 x constant will just be a number aka constant)

Set the variable like terms equal to each other:

xa= (3+y)a, we can cancel both a so we just get x= 3 + y

Set the constants equal to each other:

18 = 3y

LOOK! we can solve for 18=3y with simple algebra, giving us y=6.

If we plug y=6 into x = 3+y, we get x=9.

That’s your answer: x=9.