To calculate the molar mass of a formula (also known as relative formula mass, or Mr), simply add together the Ar (relative atomic mass) of all the elements in that formula.

One mole of atoms or molecules of any substance will have a mass in grams equal to the relative formula mass of that substance.

So, the molar mass of MgCl2 is -
Ar of Mg = 24
Ar of Cl = 35.5. * 2 because there are two Cl.
24 + (35.5 * 2 ) = 95. So the molar mass of MgCl2 is simply 95.