What is the use of the Math.random() function in JavaScript ?
The Math.random() function is used to generate a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive). Syntax:Math.random();Example: Here, Math.random() generates a random number, which could be any floating-point value between 0 (inclusive) and 1 (exclusive). This random number is then stored in the variable randomNumber, an