Answer:
Here's what I get.
Explanation:
Mg has two electrons in its valence shell, and O has six.
Mg loses its two valence electrons to have an octet (by exposing its inner electrons). By losing two electrons, it gains two positive charges.
O gains two electrons to have an octet (by filling its valence shell). By gaining two electrons, it gains two negative charges.
The electrostatic attraction between opposite charges holds the ions together in an ionic bond.