Like the previous post states, the number of valence electrons (typically the group number for nonmetals)relates directly to the number of covalent bonds available. Additionally, when you exceed this number you create a cation and when you are less the number of potential bonds, you have created a anion.