Created
February 16, 2010 05:52
-
-
Save bga/305318 to your computer and use it in GitHub Desktop.
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
function repeatString(str, how_many) | |
{ | |
how_many|=0; // convert to number and round | |
str+=""; // convert to string | |
if(how_many<=0 || str.length==0) | |
return ""; | |
if(how_many==1) | |
return str; | |
if(how_many==2) | |
return str+str; | |
var result=""; | |
while(how_many) | |
{ | |
if(how_many&1) | |
result+=str; | |
how_many>>=1; | |
str+=str; | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment