count = 3;
setInterval(function(){
alert(count);
}, 100);
function callme(cnt) {
console.log(cnt);
cnt < 3 ? setTimeout(callme, 1000, cnt+1) : 0;
}
callme(1);
var counter = 3,
intervals = 0,
interval = setInterval(function(){
intervals++;
alert(counter);
if(counter >= 3){
clearInterval(interval);
}
}, 100);
var counter = 3,
intervals = 0,
interval = setTimeout(function f(){
intervals++;
alert(counter);
if(intervals < 3){
setTimeout(f, 100);
}
}, 100);