Facebook
From Mature Meerkat, 6 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 267
  1. //I'm downloading a button from the page
  2. const buttomRandomOne = document.getElementById("randomOne");
  3. const buttomRandomSix = document.getElementById("randomSix");
  4. const resetButton = document.getElementById("reset");
  5.  
  6.  
  7. //Create arrays
  8. const result = []
  9.  
  10.  
  11.  
  12.  
  13. //Function random once number
  14. const randomOne = function() {
  15.  
  16.     if (result.length === 6) {
  17.        return alert("Wszystkie");
  18.     };
  19.  
  20.     const div = document.createElement("div"); //Create element
  21.     const score = Math.floor (Math.random() * 49 + 1);
  22.  
  23.     for (let i = 0; i < result.length; i++) {
  24.         if (score === result[i]) {
  25.             return randomOne();
  26.         }
  27.     }
  28.  
  29.     div.textContent = score; //Value of the content
  30.     document.body.appendChild(div); //Add element
  31.  
  32.     result.push(score);
  33. }
  34.  
  35. // Function random six numbers
  36. const randomSix = function() {
  37.     for (i=0; i<=6; i++) {
  38.         randomOne;
  39.     }
  40. }
  41.  
  42.  
  43. //Function reload
  44. const functionReload = function() {
  45.     location.reload();
  46. }
  47.  
  48.  
  49. buttomRandomOne.addEventListener("click",randomOne);
  50. resetButton.addEventListener("click",functionReload);
  51. buttomRandomSix.addEventListener("click",randomSix);
  52.  
  53.