JSFiddle - React, Tailwind, and code Playground

HTML

<div id="showVal"></div>

JavaScript

var random = 0;
    var theDiv = document.getElementById("showVal");

    updateTheDiv(9,0);
    function updateTheDiv(inRange, inMin) {
        random = (Math.random()*inRange+inMin)|0; // OP said this needs to be accessible
        theDiv.innerHTML = random;

        var nextCall = (Math.random()*1000)|0;
        setTimeout(function() {
            updateTheDiv(inRange, inMin);
        }, nextCall);
    }