Atoms gain or lose electrons based on their respective electron affinity. The greater the electron affinity of an atom, the more likely that atom is to accept an electron. Electron affinity changes based on the group of elements to which an atom belongs.
There are several factors that affect the electron affinity of an atom. The effective nuclear charge is the positive charge exhibited by the protons in the nucleus of an atom. The greater the effective nuclear charge of an atom, the greater its electron affinity. Because effective nuclear charge becomes stronger when traveling from right to left on the periodic table of elements, the electron affinity across a period exhibits a similar trend. Electron affinity generally follows the same increasing and decreasing trends across a periodic table as electronegativity, and one can be used to estimate the other when comparing two atoms of different elements.
The number of electrons required to fill the outermost electron shell also affects the electron affinity of an atom. Halogens such as chlorine and iodine require only one electron to have all their electron shells completely filled, and they have a strong electron affinity. Noble gases already have completely filled electron shells and do not require additional electrons for stability, giving them a very low electron affinity.