Created
December 20, 2015 05:29
-
-
Save rurtubia/6018cb9568f9a65af6b6 to your computer and use it in GitHub Desktop.
My solution to bonfire 10 at FreeCodeCamp
Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.
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 repeat(str, num) { | |
// repeat after me | |
//return str; | |
var array = []; | |
for(i=0 ; i < num; i++) | |
{ | |
array.push(str); | |
} | |
return array.join(''); | |
} | |
repeat("abc", 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment