It seems to work, but it does not work with setTimeout , it should circle the circle, please help. If you remove setTimeout it works.
var centerx = 400, centery = 450, radius = 150; //var a=0; function muvi(a) { while (a < 6.28) { a = a + 0.1; let x = (radius * Math.cos(a)) + centerx; let y = (radius * Math.sin(a)) + centery; console.log(a); let div = document.getElementById('roundid'); div.style.left = x + "px"; div.style.top = y + "px"; document.body.appendChild(div); (function() { let j = a; setTimeout(function timer() { console.log(j); }, 100); })(); } } muvi(0); #block { position: absolute; width: 30px; height: 30px; background: #fcc; } body { position: relative; } .round, #roundid { width: 30px; height: 30px; border-radius: 50%; background-color: red; position: absolute; } <div id="roundid" class="round"></div>
setTimeoutperforms some action after some time. In this example, you needsetInterval- Air