You can determine the number of lone pairs by drawing the Lewis structure of the compound. Let's take ammonia or NH₃ molecule for example. The first thing to do is add up the valence electrons of each individual atoms.Nitrogen has 5 and Hydrogen has 1.. So, the total valence electrons is: 5 + 1(3) = 8. So, there must be 8 electrons that surround the molecule. You must distribute these to the atoms by knowing the types of bonds involved. Note that each single bond connecting two atoms in the compound contains two electrons. It is also crucial to always obey the Octet Rule. This rule states that every atom has to be filled with eight electrons in order to be stable.
The lone pairs are presented as dots while the shared electrons are presented as bonds. So, in order to determine the lone pairs of a compound, just draw their Lewis structures and count the number of dots. In this case, ammonia has one lone pair of electrons. These are the electrons that actively participate in chemical reactions.