1

Hello here I need to check the past z variable with a new one(z),please help

Hello here is what i got

<html>
    <head>
        <link rel = "stylesheet" href = "style.css">
    </head>
    <body onload = "myFunction()" id = "body">
        <div id = 'play_ground'>
        </div>
        <b2>PLAY<b2>
        <script src = "Game-9.js"></script>
    </body>
</html>
var play_box = document.getElementById('play_ground');
function myFunction(){
    for (i = 1; i <= 9; i++){
        var z = Math.floor(Math.random() * 10)
             play_box.innerHTML += '<div class = "box">'+ z +'</div>' };
        }
}

I just cant imagine how can i check the past z variable with a new one(z),please help

  • 2
    I'd initialize your array with 0-8 or 1-9, then shuffle it. https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array – mykaf Apr 14 '23 at 17:56
  • 1
    Does this answer your question? [How to randomize (shuffle) a JavaScript array?](https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array) – Mushroomator Apr 14 '23 at 18:01

0 Answers0