Well, as you know (or should know), covalent bonding results from the SHARING of electrons..........
And ionic bonding results from the transfer of electrons to form discrete positive and negative ions.
Atomic fluorine or atomic chlorine each has 7 valence electrons (of course they do; they are halogens that come from Group VII of the Periodic Table). Ideally, they would have 8 valence electrons, and one way they can do this is by reduction............i.e.
And in fact fluorine is the most potent oxidant on the Periodic Table.
Alternatively, they could form covalent bonds, in which a PAIR of electrons is shared BETWEEN the 2 nuclei.........
And thus for the elemental halogens we commonly get a homonuclear diatomic molecule. Heteronuclear diatomic molecules are also possible, so-called interhalogens i.e.