Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function repeatStringNumTimes(str, num) {
- // repeat after me
- // return num > 0 ? str.repeat(num) : '';
- let repeatedString = "";
- if (num > 0) {
- while(num > 0){
- repeatedString += str;
- num--;
- };
- return repeatedString;
- }
- return "";
- }
- repeatStringNumTimes("abc", 3);
Add Comment
Please, Sign In to add comment