javascript – Generate a dynamic grid according to the output of Math.random-ThrowExceptions

Exception or error:

starting from this code below, how can I use the output ‘x’ to generate a square sized grid that uses x as the number of rows and columns? Ideally, the grid should change according to the value of x that is generated with any new iteration.
Thank you for the help.

<!DOCTYPE html>
    <html>
    <body>

    <script>  

    // Function to generate random number  
    function randomNumber(min, max) {  
        return Math.floor(Math.random() * (max - min) + min); 
    }   

    // Function call
    x = randomNumber(2, 10)
    document.write(x);  
    </script>           

    </body>
    </html>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *