Skip to content

Instantly share code, notes, and snippets.

@AviTapp
Last active December 26, 2017 19:08
Show Gist options
  • Save AviTapp/1ff164bdb01230ebc207d0ba5e7228cc to your computer and use it in GitHub Desktop.
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.
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