Answer: Magnesium loses electrons to form

Step-by-step explanation:
An ionic bond is formed when an element completely transfers its valence electron to another element. Metals donate the electron and forms a positively charged ion called as cation. Non metals accept the electrons and forms a negatively charged ion called as anion.
Electronic configuration of magnesium:
![[Mg]:12: 1s^22s^22p^63s^2](https://img.qammunity.org/2020/formulas/chemistry/middle-school/va4pte5l798id2g0soubssrd47vig9ziwx.png)
Magnesium atom will loose one electron to gain noble gas configuration and form magnesium cation with +2 charge.
![[Mg^(2+)]:10:1s^22s^22p^63s^0](https://img.qammunity.org/2020/formulas/chemistry/middle-school/vb5p2b5jc8uqus9lu9nimnui1j2citl0hr.png)
Electronic configuration of bromine
![[Br]:35:1s^22s^22p^63s^23p^64s^23d^(10)4p^5](https://img.qammunity.org/2020/formulas/chemistry/middle-school/aeo7ccasm9cttkj95ilz08e8gu8ov1d3jo.png)
Bromine atom will gain one electron to gain noble gas configuration and form bromide ion with -1 charge.
![[Br^-]=1s^22s^22p^63s^23p^64s^23d^(10)4p^6](https://img.qammunity.org/2020/formulas/chemistry/middle-school/qly9z0szap4zm7hh3jubu7lipuhnxgo8qv.png)
Thus as magnesium forms a cation , it is the metal.