Skip to content

Instantly share code, notes, and snippets.

@waltzaround
Created October 4, 2015 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waltzaround/de7fed2da9a1bad855e1 to your computer and use it in GitHub Desktop.
Save waltzaround/de7fed2da9a1bad855e1 to your computer and use it in GitHub Desktop.
function repeat(str, num) { // we need a string and the number of times to repeat it to run our function
var contain = ""; // we create a new variable named contain
for(var repeat = 0; repeat < num; repeat++){
// we create a new variable called repeat
//as long as repeat is greater than the quantity of num, add 1 to repeat and run the code in the for statement
contain += str; //assuming top holds true, we add contain to str
}
return contain; // we then send contain out of the function
}
repeat("abc", 3, "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment