Here's why:
* Sodium (Na) is a metal and has a tendency to lose one electron to achieve a stable electron configuration.
* Chlorine (Cl) is a nonmetal and has a tendency to gain one electron to achieve a stable electron configuration.
When sodium loses an electron, it becomes a positively charged ion (Na+), and when chlorine gains an electron, it becomes a negatively charged ion (Cl-). These oppositely charged ions are attracted to each other, forming an ionic bond and creating the compound sodium chloride (NaCl).