Guest User

Untitled

a guest
Oct 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. function repeatStringNumTimes(str, num) {
  2. // repeat after me
  3. // return num > 0 ? str.repeat(num) : '';
  4. let repeatedString = "";
  5.  
  6. if (num > 0) {
  7. while(num > 0){
  8. repeatedString += str;
  9. num--;
  10. };
  11.  
  12. return repeatedString;
  13. }
  14.  
  15. return "";
  16. }
  17.  
  18. repeatStringNumTimes("abc", 3);
Add Comment
Please, Sign In to add comment