Suppose you are given the atomic number of an element, e.g. Technetium, which is 43. Is it possible to return an array which shows the distribution of electrons across different shells of an atom using vanilla JavaScript?

Example Input/Output:

Atomic number Electronic configuration
20 (Calcium) [2, 8, 8, 2]
43 (Technetium) [2, 8, 18, 13, 2]
50 (Tin) [2, 8, 18, 18, 4]

1 Answer 1


Yes - you can just pre-calculate them and hard-code them into your code, so that the script is simply a conditional switch that returns the required array when given the atomic number, without any actual calculation. Although this gives a script that is much longer than it needs to be, it's less susceptible to unexpected errors, since the shell occupation numbers of many metal atoms are irregular and must be treated separately anyway. You only need to watch out for copy-paste errors. Most (if not all) computational chemistry codes I know of, that implement this functionality, indeed hard-code the numbers, rather than relying on a generic formula and accounting for its exceptions separately.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .