If an atom has lost or gained electrons by changing to a cation or anion, follow these steps:
Add an electron to the anion electron configuration. For example, the ground state electronic configuration of chlorine is 1s²2s²2p⁶3s²3p⁵. For Cl−, it will be 1s²2s²2p⁶3s²3p⁶.
Remove the outermost electrons in the cation, e.g. electron configuration for Mg2+ will be 1s²2s²2p⁶.
Read more