The 10 foot ladder is the hypotenuse of the right triangle. The distance of the base of the ladder to the building (6 feet) is a leg. The height of the building is the other leg.
Using the Pythagorean Theorem: height^2 + 6^2 = 10^2 --> height^2 = 64 ---> height = 8