please dont close this as its not the same as an undefined var that you think this is the same question as its not.
Trying to change a global var from inside an async function then read it from outside the function, I will pop example on oh and i'm new to javascript, now if I read the value from inside the function its fine but not from outside. EDIT forgot to say its webaccess the var I'm wanting to use.
var webaccess = (0);
async function run() {
var result = (0);
result = await contract.methods.name().call()
console.log(`Token name: ${result}`)
result = await contract.methods.balanceOf(account1).call()
console.log(`Balance of account #1: ${result}`)
if (result >= "10000000000000000000" && result < "12000000000000000000"){
webaccess = (1);
}
if (result >= "12000000000000000000" && result < "14000000000000000000"){
webaccess = (2);
}
if (result >= "14000000000000000000" && result < "16000000000000000000"){
webaccess = (3);
}
if (result >= "16000000000000000000" && result < "18000000000000000000"){
webaccess = (4);
}
if (result >= "18000000000000000000" && result < "20000000000000000000"){
webaccess = (5);
}
}
run()
if (webaccess == (1)){
console.log(`webaccess pass = ${webaccess}`);
}
if (webaccess == (2)){
console.log(`webaccess pass = ${webaccess}`);
}
if (webaccess == (3)){
console.log(`webaccess pass = ${webaccess}`);
}
if (webaccess == (4)){
console.log(`webaccess pass = ${webaccess}`);
}
if (webaccess == (5)){
console.log(`webaccess pass = ${webaccess}`);
}