Why is the chemical formula for magnesium chloride #"MgCl"_2"#?
Refer to the explanation.
If the Mg atom loses its two valence electrons, it will become stable because the next lower energy level will have eight valence electrons (an octet). If a Cl atom gains one electron, it will have eight valence electrons.
Since Mg needs to lose two valence electrons, it is required that two Cl atoms each gain one Mg valence electron. The Mg atom becomes a