To answer what the midpoint of AB is simply replace the values in the formula to find the coordinates of the midpoint.
In this case these are (2 + 4) / 2 = 3 and (6 + 18) / 2 = 12. So (xM, yM) = (3, 12) is the midpoint of the segment defined by A and B.