It depends on the number of electrons in outermost shell. Generally elements with 1,2 or 3 electrons in its outermost shell will tends to lose electrons. Elements with 4 electrons like to share electrons and form covalent bonds. Elements with 5,6 or 7 electrons generally tends to gain electrons.