Learn
Exam

String Multiplication

Difficulty
STARTER

Problem

Given a string word and a natural number n, write a function solution that returns the result of repeating the string word exactly n times.


Constraints

  • word consists only of lowercase English letters.
  • The length of word is between 1 and 100 inclusive.
  • n is a natural number between 1 and 10 inclusive.

Test Case

Test Case Number word n return
1 "abc" 3 "abcabcabc"
2 "hello" 2 "hellohello"
3 "a" 5 "aaaaa"

Explanation for Test Case 1

  • When word = "abc" and n = 3, the result of repeating "abc" 3 times is "abcabcabc".

Explanation for Test Case 2

  • When word = "hello" and n = 2, the result of repeating "hello" 2 times is "hellohello".

Explanation for Test Case 3

  • When word = "a" and n = 5, the result of repeating "a" 5 times is "aaaaa".