Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robertsheacole/2ef7e8cec42fd07aaf8b to your computer and use it in GitHub Desktop.
Save robertsheacole/2ef7e8cec42fd07aaf8b to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/robertsheacole 's solution for Bonfire: Repeat a string repeat a string
// Bonfire: Repeat a string repeat a string
// Author: @robertsheacole
// 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) {
if (num >= 0){
return str.repeat(num);
} else {
return "";
}
}
console.log(repeat("abc", -3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment