How atoms interact
Atoms bond so that each one ends up with a full outer shell. A metal gives its outer electrons to a non-metal, two non-metals share theirs, and metal atoms pool theirs in a sea of electrons.
A worked example
Sodium has 1 outer electron and chlorine has 7. Sodium gives its electron to chlorine, so both end up with full outer shells, as the ions Na⁺ and Cl⁻. The attraction between those opposite charges is an ionic bond. In hydrogen chloride, HCl, both atoms are non-metals, so they share a pair of electrons instead. Chlorine's electronegativity is 3.2 and hydrogen's is 2.2, so ΔEN = 3.2 − 2.2 = 1.0. Chlorine pulls the shared pair closer, so it becomes δ− and hydrogen becomes δ+.
The mistake people actually make
Sharing isn't always equal. A covalent bond between two different non-metals is usually polar, so calculate ΔEN before you call the sharing even. A noble gas already has a full outer shell, which is why it does not bond.