how to repeat result from math.random in javascript?

iamwhitehat

just to clarify my question, i need to generate a 2 digits numbers separately to make it set of 6 like this "12,45,24,63,64,1"

<html>
 <head>
    <title>lotto picker</title>

 </head>
 <body>


    <p> I can generate you a lotto numbers to bet right now!</p>
    <button id="generateButton">Generate!</button>

 <script type="text/javascript">
   document.getElementById("generateButton").onclick = function() {

                var msg = " ";
                var lottoNum = Math.floor((Math.random() * 64) + 1);


                alert(lottoNum);


            }
 </script>
 </body>


</html>
Hassan Imam

To generate 6 2-digit number you need to loop six times. Below is the program to generate 6 2-digit number

document.getElementById("generateButton").onclick = function() {
                var msg = " ";
                for(var i = 0 ;i < 6 ; ++i) {
                var lottoNum = Math.floor(Math.random() * 89) + 10;
                msg += lottoNum + ",";
                }
                msg = msg.slice(0, -1);
                alert(msg);
            }
<html>
<head>
    <title>lotto picker</title>
</head>

<body>
    <p> I can generate you a lotto numbers to bet right now!</p>
    <button id="generateButton">Generate!</button>
</body>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get unique numbers from Math.random in javascript?

From Dev

How to get unique numbers from Math.random in javascript?

From Dev

don't repeat any items from math.random

From Dev

Javascript Math.random() not *that* random…?

From Dev

Math & JavaScript | Random chances

From Dev

How to get random math operator for a quiz qustion in javascript

From Dev

How to get random math operator for a quiz qustion in javascript

From Dev

How do you create a button that will display a random result from an array in javascript?

From Dev

Math.Random in function always the same result

From Dev

Javascript - Math.random as parameter

From Dev

Javascript - Get checkbox values from a form and get a random result

From Dev

How to take random element from array without repeat and put it to textarea

From Dev

Unexpected result from math expression

From Dev

Java Math.random() How random is it?

From Dev

how to ng-repeat values for result from filter

From Dev

How can I get a random result from an array, then based on that result get another random result from another array?

From Dev

How does the distribution of Math.random()*50 + Math.random()*20 compare to Math.random()*70?

From Dev

How do we select a random row from a mysql result?

From Dev

Bash: how to avoid duplicate result from random list?

From Dev

How to make random combination not to repeat?

From Dev

javascript TypeError: Math.random is not a function on chrome

From Dev

Math.random and web programming in JavaScript

From Dev

Math.random() javascript function *undefined* on Chrome

From Dev

Javascript Math.random() and conditional expressions

From Dev

How to get a random character from a range in JavaScript?

From Dev

How to use math.random again to get a different value if the values are the same in javascript

From Dev

Generate a random math Equation using Random numbers and operators in Javascript

From Dev

How to get result from a JavaScript file in Java

From Dev

How get a result from checkbox javascript

Related Related

  1. 1

    How to get unique numbers from Math.random in javascript?

  2. 2

    How to get unique numbers from Math.random in javascript?

  3. 3

    don't repeat any items from math.random

  4. 4

    Javascript Math.random() not *that* random…?

  5. 5

    Math & JavaScript | Random chances

  6. 6

    How to get random math operator for a quiz qustion in javascript

  7. 7

    How to get random math operator for a quiz qustion in javascript

  8. 8

    How do you create a button that will display a random result from an array in javascript?

  9. 9

    Math.Random in function always the same result

  10. 10

    Javascript - Math.random as parameter

  11. 11

    Javascript - Get checkbox values from a form and get a random result

  12. 12

    How to take random element from array without repeat and put it to textarea

  13. 13

    Unexpected result from math expression

  14. 14

    Java Math.random() How random is it?

  15. 15

    how to ng-repeat values for result from filter

  16. 16

    How can I get a random result from an array, then based on that result get another random result from another array?

  17. 17

    How does the distribution of Math.random()*50 + Math.random()*20 compare to Math.random()*70?

  18. 18

    How do we select a random row from a mysql result?

  19. 19

    Bash: how to avoid duplicate result from random list?

  20. 20

    How to make random combination not to repeat?

  21. 21

    javascript TypeError: Math.random is not a function on chrome

  22. 22

    Math.random and web programming in JavaScript

  23. 23

    Math.random() javascript function *undefined* on Chrome

  24. 24

    Javascript Math.random() and conditional expressions

  25. 25

    How to get a random character from a range in JavaScript?

  26. 26

    How to use math.random again to get a different value if the values are the same in javascript

  27. 27

    Generate a random math Equation using Random numbers and operators in Javascript

  28. 28

    How to get result from a JavaScript file in Java

  29. 29

    How get a result from checkbox javascript

HotTag

Archive