# Random function & unique random numbers

**URL:** <https://forum.kirupa.com/t/random-function-unique-random-numbers/160959>\
**Category:** flash\
**Created:** [August 30, 2005, 11:25pm UTC](https://forum.kirupa.com/t/random-function-unique-random-numbers/160959 "2005-08-30T23:25:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carradine](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@Carradine](https://forum.kirupa.com/u/Carradine)\
**Post date:** [August 30, 2005, 11:25pm UTC](https://forum.kirupa.com/t/random-function-unique-random-numbers/160959/1 "2005-08-30T23:25:19Z")

</div>

Hello, after some searching i can’t seem to find any good explanation to how and why i should use the Math.random() function so maybe i should explain how a function i need should work and someone maybe has some ideas.

I’m making a guessing program where you guess the right answer.

The function i have now randomly selects a number from 0 to 5 and then put’s these five numbers into an array, the thing is that i need the numbers to be unique and i have no idea on how to make this.

Another thing i need to do is between these numbers that the random() function gets one is to be removed and instead i put the right answer there so now i also need one of the randomizes numbers to not be the right answer.

Also, how should a Math.random() function call look like so i can edit the range of numbers to randomize from?
