Something like this? It uses setTimeout
rather than setInterval
.
var write = function (count) {
$('#followcounter').text(count);
};
var count = 0;
function looper() {
count++;
var delay = (count === 3 || count === 8) ? 5000 : 1
var timer = setTimeout(function () {
if (count > 10) {
$('#followcounter').text('End all');
clearTimeout(timer);
} else {
write(count);
looper();
}
}, delay);
};
looper();