As chlorine has 7 valence electrons and sodium has 1 valence electron so to become stable and complete their octets sodium will become a cation by losing one electron and chlorine will form an anion and will gain one electron in this way both will become stable and an ionic bond will form between sodium and chlorine
Chemical formula:
Na + Cl —> NaCl