I have a Boolean function, and in some cases i need it to wait for 6 secs before returning.
I am trying to do something like:
function myFunc() {
if (pending) {
setTimeout(return true, 6000);
} else {
return false;
}
}
The reason I use setTimeout, is that i have some other code running in the same time, and I want to be able to cancel the setTimeout.
Can anyone please help?
Thank you!!