Here's why:
* Sodium (Na) is a metal and tends to lose one electron to achieve a stable electron configuration.
* Chlorine (Cl) is a nonmetal and tends to gain one electron to achieve a stable electron configuration.
When sodium and chlorine react, sodium loses an electron, becoming a positively charged ion (Na+), and chlorine gains that electron, becoming a negatively charged ion (Cl-). These oppositely charged ions attract each other strongly, forming an ionic bond.