# JS: Random Range Function

## How to generate a random number?

`Math.random()`

→ return a a pseudo-random number between 0 to 1. (including 0 but excluding 1)

[see JS: Math]

## How to get a random real number between min and max?

// es2015 // random real number in range {min, max}, including min but excluding max. version 2017-05-12 const xah_random_real = ((xmin,xmax) => ( Math.random() * (xmax - xmin) + xmin));

## How to get a random integer?

// es2015 // random integer in range {min, max}, including min and max const xah_random_int = ((xmin,xmax) => (Math.floor( Math.random() * (xmax + 1 - xmin) + xmin ))) ;

## How is random number seeded?

It's based on current time.

## How to seed random number?

You can't.

## Random Array Element, Randomize Array

JS: Random Array Element, Randomize Array

If you have a question, put $5 at patreon and message me.