I am trying to make a js script that will make a canvas and then place 4 circles on it. Circles x and y coordinates should be 8-180px, and the size of it should be 13-40px.
How I understand the page is crashing because of those two "while" loops, that I made to find the coordinates for the circles. Can someone please tell me if am I right and how to solve this? Thank you :>
Here's the code:
<body>
    <canvas id=myCanvas width=380 height=380 style="background-color: red;"> </canvas>
    <script>
    function fc(x, y, radius) {
        ctx.beginPath();
        ctx.arc(x, y, radius, 0, Math.PI * 2);
        ctx.fill();
    }
    function RandInt(up_to) {
        n = Math.floor(Math.random() * up_to);
        return(n);
    }
    var ctx = myCanvas.getContext("2d");
    var a = 8
    var i = 4
    var ir = 1
    var fcxmin = a
    var fcymin = a
    var fcxmax = 180
    var fcymax = 180
    while (i!= 0) {
        var ir = RandInt(40)
        if (ir >= a+5) {
            var fcxwh = 1
            while (fcxwh = 1) {
                var fcx = RandInt(fcxmax)
                if (fcx >= fcxmin) {
                    fcxwh = 0
                }
            }
            var fcywh = 1
            while (fcywh = 1) {
                var fcy = RandInt(fcymax)
                if (fcy >= fcymin) {
                    fcywh = 0
                }
            }
            fc(fcx, fcy, ir)
            var i = i - 1
        } else {
            alert("RandInt gave a number lower than 13.")
        }
    }
    // Your code goes here! 
    // If you're not sure how to code Javascript, go back and read the S2JS tutorials 
    </script>
    
</body>
 
     
     
    