Last active
April 5, 2016 01:07
-
-
Save mmloveaa/6b05b865ba85140850f561ced805fefa to your computer and use it in GitHub Desktop.
4-4 FCC Q8 - 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
Repeat a string repeat a string | |
Repeat a given string (first argument) num times (second argument). Return an empty string if num is a negative number. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: | |
Global String Object | |
function repeatStringNumTimes(str, num) { | |
// repeat after me | |
if(num<0){ | |
return ""; | |
} else { | |
return str.repeat(num); | |
} | |
} | |
repeatStringNumTimes("abc", 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment