Skip to content

Instantly share code, notes, and snippets.

@sebshub
Created December 2, 2016 22:01
Show Gist options
  • Save sebshub/8b9fa85afa9eb64384f8cb4805b2d885 to your computer and use it in GitHub Desktop.
Save sebshub/8b9fa85afa9eb64384f8cb4805b2d885 to your computer and use it in GitHub Desktop.
Repeat a string repeat a string FCC
function repeatStringNumTimes(str, num) {
// repeat after me
if (num > 0) {
return str.repeat(num);
} else {
return "";
}
}
repeatStringNumTimes("abc", 3);
@sebshub
Copy link
Author

sebshub commented Dec 2, 2016

freecodecamp Exercise
Repeat a given string (first argument) num times (second argument). Return an empty string if num is not a positive number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment