Ionic compounds are molecules that form through the gain and loss of electrons. A metal atom that loses an electron takes on a positive electric charge .