Created
December 2, 2016 22:01
-
-
Save sebshub/8b9fa85afa9eb64384f8cb4805b2d885 to your computer and use it in GitHub Desktop.
Repeat a string repeat a string FCC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeatStringNumTimes(str, num) { | |
// repeat after me | |
if (num > 0) { | |
return str.repeat(num); | |
} else { | |
return ""; | |
} | |
} | |
repeatStringNumTimes("abc", 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
freecodecamp Exercise
Repeat a given string (first argument) num times (second argument). Return an empty string if num is not a positive number.