Method 1: Using Math.random() function: The Math.random() function is used to return a floating-point pseudo-random number between range [0,1), 0 (inclusive), and 1 (exclusive). This random number can then be scaled according to the desired range.
Example 1: This example generates an integer random number between 1(min) and 5(max).
Random Number between 1 and 5: 1.0573617826058959
Example 1: This example generates a random integer number between 1(min) and 100(max).
Random Number between 1 and 100: 87
Example 2: This example generates a random whole number between 1(min) and 10(max) both inclusive.
Random Number between 1 and 10: 3
Please Login to comment...