Ionic compounds stay together because opposite charges attract. Molecules stay together because the atoms are sharing electrons. These are two very different reasons why atoms stay together. Behind both of them, however, is the tendency toward having the same number of electrons as a noble gas.
An interesting thing about sharing is that it isn't always even. This results in some very interesting everyday observations!
The following lessons are available in this section: