JSFiddle - React, Tailwind, and code Playground
HTML
<div id="hero">
</div>
CSS
#hero{
position: absolute;
background-color: #f00;
width: 20px;
height: 20px;
}
JavaScript
var kleur="#f00";
var w=100;
init();
function init()
{
setInterval(gameloop,250);
}
function gameloop()
{
var hero_variable=document.getElementById("hero");
hero_variable.style.left=w+"px";
w=w+2;
}