Skip to content

Instantly share code, notes, and snippets.

@brainyfarm
Created June 21, 2016 14:35
Show Gist options
  • Save brainyfarm/fd904b67e1afcca38385fc325bc2ab94 to your computer and use it in GitHub Desktop.
Save brainyfarm/fd904b67e1afcca38385fc325bc2ab94 to your computer and use it in GitHub Desktop.
Olawale/FreeCodeCamp Algorithm: Repeat a String
function repeatStringNumTimes(str, num) {
// Repeat and return if num is greater than 0 and if not, return an empty string
return num > 0 ? str.repeat(num) : "";
}
repeatStringNumTimes("abc", 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment