We can measure a quantity of matter using mass, but in chemical reactions it is often important to consider the number of atoms of each element present in each sample. Even the smallest quantity of a substance will contain billions of atoms, so chemists generally use the mole as the unit for the amount of substance. One mole (abbreviated mol) is equal to the number of atoms in 12 grams of carbon-12; this number is referred to as Avogadro's number and has been measured as approximately 6.022 x 1023. In other words, a mole is the amount of substance that contains as many entities (atoms, or other particles) as there are atoms in 12 grams of pure carbon-12.
Each ion, or atom, has a particular mass; similarly, each mole of a given pure substance also has a definite mass. The mass of one mole of atoms of a pure element in grams is equivalent to the atomic weight of that element in atomic mass units (amu). We call "molar mass" the mass of a given substance divided by the amount of that substance, and we measure it in grams/mole. For example, if you obtain a pure sample of titanium, whose atomic weight is 47.88 amu, and measure 47.88 grams of it, you will have one mole of titanium -- 6.022 x 1023 titanium atoms.
The characteristic molar mass of an element is calculated by multiplying the atomic weight of the element by the molar mass constant (1 g/mol). To calculate the molar mass of a compound, you need to first sum all the atomic weights of the constituent atoms. For example, the molar mass of NaCl is determined as follows (22.99 is the atomic mass of sodium, which 35.45 is the atomic mass of chlorine):
(22.99 + 35.45) x 1 g/mol = 58.443 g/mol