I'm facing an issue with incrementing the variable loopVal inside a promise. I've tried to increment it without success. Any ideas on how to make this work?
const hi = function(delay) {
let loopVal = 1;
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Resolved Successfully", loopVal);
resolve();
loopVal++;
}, delay)
})
}
const bye = async() => {
await hi(1000);
await hi(1000);
return "bye";
}
bye().then((value) => console.log(value));