123456789101112131415161718192021222324252627282930313233343536 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 0.999999
- // 0.000000001
- // 1-9 0-8
- function game(){
- var num1 = Math.floor(Math.random()*9)+1;
- var num2 = Math.floor(Math.random()*9)+1;
- var num3 = Math.floor(Math.random()*9)+1;
- if(num1 == 8 || num2 == 8 || num3 == 8){
- console.log(num1,num2,num3);
- return true
- }else{
- return false
- }
- }
- var win = 0;//赢的次数
- for(var i = 0;i<10;i++){
- if(game()){
- win++;
- }
- }
- console.log((win/10)*100 + "%");
-
-
- </script>
- </body>
- </html>
|