Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrjames83/e8d63f0b97eadfe95118 to your computer and use it in GitHub Desktop.
Save jrjames83/e8d63f0b97eadfe95118 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/fcc0208647c 's solution for Bonfire: Repeat a string repeat a string
// Bonfire: Repeat a string repeat a string
// Author: @fcc0208647c
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function repeat(str, num) {
stuff = [];
if (num <= 0) {
return "";
} else {
for (i = 0; i < num; i++) {
stuff.push(str);
}
}
return stuff.join('');
}
repeat("abc", 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment