The function is
function getnumber(tt1){
var hy=0;
var ic=0;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && 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] + "&sort=created&order=asc";
xhttp.open("GET", url, true);
xhttp.send();
console.log(hy); // but in here it still 0
confuse about the hy variable in the same function, but value is different.