Because CD is the perpendicular bisector of AB, this means that AB is divided into two equal parts. So, AD = DB.
AD = 6x - 2 and DB = 2x + 18, so:
6x - 2 = 2x + 18
We can use algebra to solve for x.
Adding 2 to both sides gives you
6x = 2x + 20
Subtracting 2x from both sides gives you
4x = 20
Dividing by 4 on both sides gives you
x = 5
And there's your solution.