javascript - How to generate non-equal random numbers -


I am trying to find 10 random numbers between 100 and 1000 and if any number is equal, Select the random number. Does anyone have to do this?

  & lt; Script type = "text / javascript" & gt; Var number = []; Var maximum = 110; Var min = 100; Number [1] = monastery.flur (mathematics.rendum) * (max - min + 1)) + minute; Numbers [2] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Number [3] = math.flur (math.rendum) * (maximum - min + 1)) + minute; Numbers [4] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [5] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [6] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [7] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [8] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [9] = Math. Floor (Math.Random) * (Maximum - Min + 1)) + Minute; Numbers [10] = Math. Floor (Math. Random) * (Maximum - Min + 1)) + Minute; Do (numbers [2]); While (numbers [1] === numbers [2]); Do (number [3]); While (numbers [1] == numbers [3]) (number [2] == numbers [3]); For (in number) {document.writeln ("& lt; br>" + number [i]); } & Lt; / Script & gt;  

You can do something like this

  & Lt; Script & gt; Var foo = {} while (Object.keys (foo). Length <10) {foo [Math.floor (Math.random () * (max - min + 1)) + min] = true; } Var number = object. Kids (Foo); & Lt; / Script & gt;  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -