[ Team LiB ] |

## 2.7 Generating Pseudorandom NumbersNN 2, IE 3 ## 2.7.1 ProblemYou want to generate a random number. ## 2.7.2 SolutionThe var result = Math.floor(Math.random( ) * ( where var result = Math.floor(Math.random( ) * ( where is the highest
acceptable integer of the range.
n## 2.7.3 DiscussionThe previous examples focus on random integers, such as the kind you
might use for values of a game cube (a die with numbers from 1
through 6). But you can remove the JavaScript's random number generator does not provide a mechanism for adjusting the seed to assure more genuine randomness. Thus, at best you can treat it as a pseudorandom number generator. ## 2.7.4 See AlsoSection 2.0.2 in the introduction of this chapter. |

[ Team LiB ] |