Created
June 21, 2016 14:35
-
-
Save brainyfarm/fd904b67e1afcca38385fc325bc2ab94 to your computer and use it in GitHub Desktop.
Olawale/FreeCodeCamp Algorithm: Repeat a String
This file contains hidden or 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 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