Last active
December 26, 2017 19:08
-
-
Save AviTapp/1ff164bdb01230ebc207d0ba5e7228cc to your computer and use it in GitHub Desktop.
Repeat a given string (first argument) num times (second argument). Return an empty string if num is not a positive number.
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(r, e) { | |
var n = r; | |
if (!(e > 0)) return ""; | |
for (i = --e; i > 0; i--) r += n; | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment