JSFiddle - React, Tailwind, and code Playground

HTML

<body>

<p>Click the button to display a random number.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>
<script>
function myFunction() {
    var x = 0;
    var y = 0;
    while (x < 10000000) {
        x = Math.random();
        x = Math.floor(x * 100000000);
    }
    x = x * 10;
    var t = x.toString();
    for (i = 9 ;i > 1 ; i--) {
        y = y + Number(t.charAt(9 - i)) * i;
    }
    y = y % 11;
    x = x + y;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>