Awesome! If Atom A gets an extra electron, it has \(8\) electrons in its outermost orbit. If Atom B gives up its electron in the outermost orbit, its new outermost orbit has \(8\) electrons.
So, if this "transfer" of electron happens, both Atom A and Atom B will have \(8\) electrons in their outermost orbit. As that is the goal of atoms, both atoms will try to get into this situation.

In fact, Atom A is nothing but Chlorine, and Atom B is nothing but Sodium. If Atom A and Atom B share an electron, they form Sodium Chloride, which is just the salt we use for cooking!