Generate Random Fractions with JavaScript JavaScript has a Math.random() function that generates a random decimal number.