String
-
Programmers - 문자 반복 출력하기 (Javascript)개발/코딩 테스트 2022. 12. 13. 16:22
문자열 my_string과 정수 n이 매개변수로 주어질 때, my_string에 들어있는 각 문자를 n만큼 반복한 문자열을 반환하는 문제 [나의 풀이] 1 2 3 4 5 6 7 8 9 10 11 12 function solution(my_string, n) { const answer = []; const converted = my_string.split(''); converted.forEach(string => { for ( let i = 0; i v.repeat(n)).join(""); return answer; } Colored by Color Scripter cs String의 내장 메소드 중 repeat() 함수를 활용한 부분이 눈에 띄어 기록한다.