Question: how do you know how many electrons an element gains or loses?
Answer: In general, metals will lose electrons to become a positive cation and nonmetals will gain electrons to become a negative anion. Hydrogen is an exception, as it will usually lose its electron. Metalloids and some metals can be can lose or gain electrons.