Step-by-step explanation:
(The answer is the attached image)
Magnesium is a metal and has two valence electrons, while sulfur is a nonmetal that has six valence electrons. Thus, to achieve a full octet, magnesium wants to lose its two valence electrons and sulfur wants to gain two valence electrons. The two valence electrons of magnesium are transferred to the sulfur atoms, causing both the Mg2+ ion and the S2- ion to have full octets.