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

don't repeat any items from math.random

From Dev

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

From Dev

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

From Dev

Math.random and web programming in JavaScript

From Dev

Java Math.random() How random is it?

From Dev

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

From Dev

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

From Dev

How to fill an array with random numbers from 0 to 99 using the class Math?

From Dev

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

From Dev

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

From Dev

how to ng-repeat values for result from filter

From Dev

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

From Dev

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

From Dev

Unexpected result from math expression

From Dev

How to make random combination not to repeat?

From Dev

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

From Dev

Javascript - Math.random as parameter

From Dev

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

From Dev

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

From Dev

How to get result from a JavaScript file in Java

From Dev

Math.Random in function always the same result

From Dev

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

From Dev

Bash: how to avoid duplicate result from random list?

From Dev

How do I get the full decimal expansion from Perl's Math::Random::Secure?

From Dev

Math & JavaScript | Random chances

From Dev

How get a result from checkbox javascript

From Dev

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

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

Javascript Math.random() and conditional expressions

Related Related

  1. 1

    don't repeat any items from math.random

  2. 2

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

  3. 3

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

  4. 4

    Math.random and web programming in JavaScript

  5. 5

    Java Math.random() How random is it?

  6. 6

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

  7. 7

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

  8. 8

    How to fill an array with random numbers from 0 to 99 using the class Math?

  9. 9

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

  10. 10

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

  11. 11

    how to ng-repeat values for result from filter

  12. 12

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

  13. 13

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

  14. 14

    Unexpected result from math expression

  15. 15

    How to make random combination not to repeat?

  16. 16

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

  17. 17

    Javascript - Math.random as parameter

  18. 18

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

  19. 19

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

  20. 20

    How to get result from a JavaScript file in Java

  21. 21

    Math.Random in function always the same result

  22. 22

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

  23. 23

    Bash: how to avoid duplicate result from random list?

  24. 24

    How do I get the full decimal expansion from Perl's Math::Random::Secure?

  25. 25

    Math & JavaScript | Random chances

  26. 26

    How get a result from checkbox javascript

  27. 27

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

  28. 28

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

  29. 29

    Javascript Math.random() and conditional expressions

HotTag

Archive