Answer: The ionic compound formed is magnesium chloride having formula

Step-by-step explanation:
Ionic compound is defined as the compound which is formed by complete transfer of electrons from one atom to another atom.
The atom which looses the electron is known as electropositive atom and the atom which gains the electron is known as electronegative atom. This bond is usually formed between a metal and a non-metal.
Magnesium is the 12th element of the periodic table having electronic configuration of

This element will loose 2 electrons to form
ion
Chlorine is the 17th element of the periodic table having electronic configuration of

This element will gain 1 electron to form
ion
So, for every 1 atom of magnesium, 2 atoms of chlorine are required. Thus, the chemical formula becomes

Hence, the ionic compound formed is magnesium chloride having formula
