I tried to make a flaying window with interval 2s What is Wrong with my code?


<-- try to move the new window diagonally with live server but the set interval doesn't work i trace it with debug i saw it's not working
-->




 <!DOCTYPE html>
<html lang="en">

<head>



    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="move">Move</button>
    <button id="close">Close</button>

    <script >var win = window.open('https://www.google.com', '', 'width= 150 height =150');
        var x = 50,
          y = 50;
        var a = 20,
          b = 20;
        var move = true;
        function movebyf() {
          while (move) {
            win.moveBy(x, y);
            win.focus();
            if (a > 426 || b > 406) {
              x = -50;
              y = -50;
              a -= 50;
              b -= 50;
            } else {
              a += 50;
              b += 50;
            }
          }
        }
        document.getElementById('close').addEventListener('click', () => {
          win.close();
          move = false;`enter code here`
        });
        setInterval(movebyf, 2000);</script>
</body>

</html>