> For the complete documentation index, see [llms.txt](https://songeun.gitbook.io/coding-test/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://songeun.gitbook.io/coding-test/lv.0/26.md).

# 문자 반복 출력하기

## **문제**

문자열 `my_string`과 정수 `n`이 매개변수로 주어질 때, `my_string`에 들어있는 각 문자를 `n`만큼 반복한 문자열을 return 하도록 solution 함수를 완성해보세요.

***

**제한사항**

* 2 ≤ `my_string` 길이 ≤ 5
* 2 ≤ `n` ≤ 10
* "my\_string"은 영어 대소문자로 이루어져 있습니다.

***

**입출력 예**

| my\_string | n | result            |
| ---------- | - | ----------------- |
| "hello"    | 3 | "hhheeellllllooo" |

***

**입출력 예 설명**

입출력 예 #1

* "hello"의 각 문자를 세 번씩 반복한 "hhheeellllllooo"를 return 합니다.

## 코드

```javascript
function solution(my_string, n) {
    let answer = [];
    my_string.split('').forEach(str => {
        answer.push(str.repeat(n));
    })
    return answer.join('')
}
```

### 다른 풀이

```javascript
function solution(my_string, n) {
    var answer = [...my_string].map(v => v.repeat(n)).join("");
    return answer;
}
```
