function go() { if (go.count < 4) { // logs 1, 2, 3 to firebug console at 1 second intervals console.log(go.count++); window.setTimeout(go, 1000); } } go.count = 1; go();