Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- Anzahl der W¨rfel<input type="text" id="anz" /> <input type="button" value="wuerfel" onClick="roll()" />
- <script>
- function roll(){
- result = 0
- anz = document.getElementById("anz").value;
- for(i = 1; i<= anz; i++){
- bla = parseInt( Math.random() * 6)+1
- if (bla == 5)result++;
- if(bla == 6){
- result++;
- i--;
- }
- }
- document.getElementById("result").innerText = result;
- }
- function paar(){
- paar = 0
- menge = document.getElementById("menge").value;
- for(i = 1; i<= menge; i++){
- dice1 = parseInt( Math.random() * 6)+1;
- dice2 = parseInt( Math.random() * 6)+1;
- if(dice1 == dice2) paar++;
- }
- document.getElementById("result").innerText = "anzahl der Pasche"+paar;
- }
- </script><br />
- Anzahl der Würfe <input type="text" id="menge" /> <input type="button" value="wuerfel" onClick="paar()" />
- <p id ="result" ></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement