Question: how many electrons does magnesium need to fill its valence shell?
Answer: Now, magnesium, Mg , has 2 valence electrons. In order to complete its octet, it must get to 8 valence electrons. The only way for magnesium to accomplish this is to give up its two valence electrons and have one of its filled energy levels become the valence shell, i.e. the outermost energy level.