Sharing instead of transferring
Transferring an electron is not the only way to fill a shell. Two atoms can also share a pair of electrons, and both count the shared pair as their own.
This works when neither atom is willing to hand electrons over. Two chlorine atoms both pull hard on electrons, so no transfer is possible between them — but if each contributes one electron to a shared pair, both end up counting eight in the outer shell.
Covalent bond
The bond formed when a pair of atoms hold electrons jointly between them, so that each reaches a stable noble-gas configuration.
No ions appear. Nothing has been given away, so nothing is charged, and the result is a discrete particle called a molecule.
Two families of molecule
Atoms of the same element sharing with each other.
Atoms of different elements sharing with each other.
Counting a shared pair twice
A shared pair belongs to both atoms at once. When you check whether an atom has reached eight, count every electron in every pair it shares — the pair is not split between them.