const name = async() => {
setTimeout(() => {
return Promise.resolve("1")
}, 1000);
};
(async function() {
console.log("hello2");
})();
const timer = async() => {
console.log(await name());
console.log("hello4");
};
timer()
expected output:
hello2
1
hello4
output is:
hello2
undefined
hello4
If i removed the settimeout function and return a promise alobe like this
const name = async () => {
return Promise.resolve("1")
};
function is returning 1 and it is getting resolved, what is the issue with when i am returning with settimeout function