Random Number With Minimum And Maximum

This code produces a random number between the defined minimum and maximum:

01function get_random_number_min_max(min, max) {
02 return Math.floor(
03 (Math.random() * (max - min + 1))
04 + min
05 )
06}
..
  

console.log(get_random_number_min_max(7, 10))
->

The number is inclusive of the of min and max values so they can be returned. For example, the snippet with return either 7, 8, 9, or 10.

Here's the code outside of a function:

01const min = 7
02const max = 10
03const random_between_min_max = Math.floor(
04 (Math.random() * (max - min + 1))
05 + min
06)
..
  

console.log(random_between_min_max)
->