Explanation:
When sodium (Na) reacts with Chlorine, it transfers its 1 outermost electron to the chlorine atom.
By losing one electron sodium atom form a sodium ion (Na⁺) and Similarly, By gaining one electron chlorine atom form chloride ion (Cl⁻).
Both ion have opposite nature of charge so they are held together by electrostatic force to form Sodium chloride.