I have a function to sleep in javascript like below:
var is_sleep = true;
function sleep(time){
if (is_sleep){
is_sleep = false;
setTimeout("sleep(time)", time);
}else{
is_sleep = true;
}
}
sleep(3000);
However it runs through the statements for is_sleep=true, doesn't run through is_sleep=false statements and doesn't sleep any more.
Could someone tell what the reason is? Thank you in advance.