Magnesium (Mg) has two electrons in its outermost energy level. Oxygen (O) has six. How can a Mg atom body with an O atom?

(Edit: I already got the answer to my question. So you can either just ignore this question, or get some fr.ee points.)