Final answer:
Magnesium is a metal and it has two valence electrons. It achieves octet by losing two electrons to form an Mg²+ cation.
Step-by-step explanation:
Magnesium is a metal and is located in Group 2 of the periodic table. It has an atomic number of 12, which means it has 12 electrons. The electron configuration of magnesium is 1s² 2s² 2p⁶ 3s².
In order to achieve a stable electron configuration similar to that of noble gases, magnesium tends to lose its two valence electrons (in the 3s subshell) to form a positively charged ion. The resulting magnesium ion (Mg²+) has a full electron shell and is isoelectronic with neon, a noble gas.