Created
October 20, 2010 14:32
-
-
Save johnfmorton/636533 to your computer and use it in GitHub Desktop.
Extending Number - class exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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