Source Code: (back to article)
<head>
<style>
#square {
width: 50px;
height: 50px;
background-color: red;
position: absolute;
left: 0;
top: 50px;
}
</style>
</head>
<body>
<div id="square"></div>
<script>
const square = document.getElementById('square');
let pos = 0;

function move() {
if (pos < window.innerWidth - 50) {
pos += 2;
square.style.left = pos + 'px';
requestAnimationFrame(move);
}
}

move();
</script>
</body>