javascript function variable value
<p>The function is</p>

<pre><code>function getnumber(tt1){
                var hy=0;
                var ic=0;
                var xhttp = new XMLHttpRequest();

                xhttp.onreadystatechange = function() {
                 if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
                   var Jsonfile= JSON.parse(xhttp.responseText);
                    hy= Jsonfile.total;
                    console.log(hy); // in here it has the value 2
                }
            };
            var url="https://hypothes.is/api/search?user=" + tt1[1] + "&amp;sort=created&amp;order=asc";
            xhttp.open("GET", url, true);
            xhttp.send();
            console.log(hy); // but in here it still 0
</code></pre>

<p>confuse about the hy variable in the same function, but value is different.</p>