//var repeatFun = repeat(alert, 10, 3000); function repeat(callback, count, interval) { return function(text) { for (var i = 0; i < count; i++) { setTimeout(function() { callback(text); }, interval * i); } } } var repeatFun = repeat(function(text) { console.log(text) }, 10, 1000); repeatFun('hello');