Skip to content

Instantly share code, notes, and snippets.

@rurtubia
Created December 20, 2015 05:29
Show Gist options
  • Save rurtubia/6018cb9568f9a65af6b6 to your computer and use it in GitHub Desktop.
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.
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