If you have one dozen small bags of sugar and one dozen large bags of salt, we can say that we have the same number of bags, 12 each. But, we do not have an equal amount in mass or grams because the bags are of different sizes and thus mass.
Similarly, we can measure sugar and salt in moles so that if I have one mole of each substance then I will have an equal number of particles of each one. That number is called Avogadro's number. One mole of any substance contains Avogadro's number of particles and is equal to 6.02 x 1023 particles. All substances have what is called molar mass. In other words, the mass in grams of one mole of that substance.
To find the molar mass of a substance, add up the individual masses of the elements that make up the substance.
Salt = NaCl ⇒ Na = 23 grams for each Na, and Cl = 35 grams for each Cl (approximately)
NaCl = 23 + 35 = 58 grams per mole.
Sugar = let us assume it is glucose = C6H12O6 ⇒ C = 12 grams per C, and H = 1 gram per H, and O = 16 grams per O.
C6H12O6 = (6 x 12) + (12 x 1) + (6 x 16) = 180 grams per mole.
If we have the same number of moles of each then we have the same number of particles. So how many moles are there in 5.0 grams of salt?
Moles of salt = (5.0 g / 58 g/mole) = 0.086 moles, so we need the same number of moles of sugar to have the same number of particles.
But how many grams is 0.086 moles of sugar? One mole = 180 grams
Grams of sugar = (0.086 moles) x (180 g/mole) = 15.52 g (did not use sig figs)