#### Answer

$x = 6$

#### Work Step by Step

We have a right triangle with the altitutde dividing the triangle into two smaller triangles; therefore, these three triangles are all similar to one another.
If these triangles are similar, then their corresponding sides are proportional.
We are given either values or expressions for the lengths of one of the legs and the hypotenuse of the big triangle and the lengths of one of the legs and the hypotenuse of a smaller triangle. Let's set up a proportion to find the value of $x$:
$\frac{x}{12} = \frac{12}{x+ 18}$
Cross multiply to get rid of the fractions:
$x(x + 18) = (12)(12)$
Multiply to simplify:
$x^2 + 18x = 144$
Move all terms to the left side of the equation:
$x^2 + 18x - 144 = 0$
Factor the quadratic equation:
$(x + 24)(x - 6) = 0$
Set each factor equal to $0$:
$x + 24 = 0$ or $x - 6 = 0$
Add or subtract to solve for $x$:
$x = -24$ or $x = 6$
We can discard the negative value because lengths cannot be negative.
Our answer is $x = 6$.