Skip to content

Instantly share code, notes, and snippets.

@mtroiani
Created December 12, 2015 01:24
Show Gist options
  • Save mtroiani/f721499b40ac1c8cd921 to your computer and use it in GitHub Desktop.
Save mtroiani/f721499b40ac1c8cd921 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mtroiani 's solution for Bonfire: Repeat a string Repeat a string
// Bonfire: Repeat a string Repeat a string
// Author: @mtroiani
// 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) {
var result = "";
if (num < 1) {
return "";
}
else {
for (var i = 0; i < num; i ++) {
result = result + str;
}
}
return result;
}
repeat("abc", 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment