Skip to content

Instantly share code, notes, and snippets.

@johnfmorton
Created October 20, 2010 14:32
Show Gist options
  • Save johnfmorton/636533 to your computer and use it in GitHub Desktop.
Save johnfmorton/636533 to your computer and use it in GitHub Desktop.
Extending Number - class exercise
// ah, wrap the function in parentheses!
Number.prototype.times = (function(theString) {
this.theString = theString;
var result = "";
for (var i = 0; i< this; i++){
result += this.theString;
}
//return this + " ; " + this.theString;
return result;
});
// now for a test of this new function
(4).times("word");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment