Ionic compounds are made up a large collection of anions and cations. The basic rule is that the ratio of cation to anions is such that the positive charges balance the negative charges. This ratio of cations to anions is known as the formul unit. For example magensium chloride has the formula unit MgCl2 , i..e., for every magnesium cation there are two chloride anions in the crystal.
The formula weight of an ionic compound is defined in the following way:
Therefore, to get the formula weight of an ionic compound we need simply determine the molar atomic mass of a formula unit. For magnesium chloride we have
Or, we would say that the formula weight of MgCl2 = 95.211 g/mol (i.e., 95.211 g of magnesium chloride has a mole of magnesium cations and 2 moles of chloride anions.