The electrical configuration of magnesium (atomic number = 12) is 2, 8, 2. It loses two electrons in its valence shell to achieve octet configuration. Electronic configuration 2, 8, 7 for chlorine (atomic number = 17). It adds one electron to its valence shell to complete the octet configuration.