The javascript: // the original code Number.prototype.times = function(str){ var mainstr = ""; for(var i=0;i < this;i++){ mainstr += str; } return mainstr; } // tweaked Number.prototype.Times = function(str){ for(var i=0;i < this;i++){ eval(str); } } Usage: var t = 4; // using the original function 4.times("a"); // returns "aaa" // using the tweaked version 4.Times("alert('a')"); // alerts 'a' 4 times