# \[FMX\] random numbers

**URL:** <https://forum.kirupa.com/t/fmx-random-numbers/133717>\
**Category:** Uncategorized\
**Created:** [January 11, 2005, 2:35pm UTC](https://forum.kirupa.com/t/fmx-random-numbers/133717 "2005-01-11T14:35:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![l\_zyboy](https://avatars.discourse-cdn.com/v4/letter/l/91b2a8/32.png) [@l\_zyboy](https://forum.kirupa.com/u/l_zyboy)\
**Post date:** [January 11, 2005, 2:35pm UTC](https://forum.kirupa.com/t/fmx-random-numbers/133717/1 "2005-01-11T14:35:02Z")

</div>

hi, i’m generating two random numbers, between 1 and 4, which must be different to each other each the two numbers are picked. i’ve tried the following: var firstRandom = Math.random()\*3+1;  
var secondRandom = Math.random()\*3+1;  
var boxA = “box”+(Math.round(firstRandom));  
var boxB = “box”+(Math.round(secondRandom));  
if (firstRandom == secondRandom) {  
var secondRandom = Math.random()\*3+1;  
var boxB = “box”+(Math.round(secondRandom));  
} else…

and i still get two numbers the same occasionally. why isn’t it comparing the numbers? is there a better way to achieve this? thanks in advance.
