String Repeating
Write a function named repeatString
that takes two parameters: str
(a string) and num
(a number). The function should return a new string that repeats the original string str
the specified number of times num
.
Example 1
Input: repeatString("abc", 3);
Output: "abcabcabc"
Example 2
Input: repeatString("hello", 2);
Output: "hellohello"
Example 3
Input: repeatString("!", 5);
Output: "!!!!!"
Are you stuck on this problem?
Get detailed, step-by-step solution and improve your JavaScript skills.
- Detailed Explanation: Each solution comes with a comprehensive explanation, helping you understand the logic and concepts thoroughly.
- Learn to Write Better Code: Even if you have written the code, discover ways to improve it and adopt best practices.
- Save Time: Don’t waste hours struggling—get the solution and learn efficiently.
- Lifetime Access: Get access to lifetime solutions for all problems available
" I struggled with this problem for hours, but the solution provided here was clear and easy to follow. It helped me understand where I went wrong and improved my coding skills significantly." - Jane D.
If you're not satisfied, I offer a 7-day money-back guarantee.