Sodium is a metal and X is a non-metal, so the bond between them is ionic. Ionic bonds form when a metal bonds with a non-metal.
Element X receives 2 electrons from Na metal and became negatively charged.