'hello'.repeat(2)
문자열 hello를 두 번 반복하여 'hellohello' 가 된다.
str = "abc";
strRepeat = str.repeat(3);
console.log(strRepeat); // abcabcabc
// `` 을 사용한다면 ${} 안에 넣어주면 된다.
str = ['1', '2', '3', '4', '5'];
for(let i = 0; i < str.length; i ++){
console.log(`${str[i].repeat(i+1)}\n`);
}
// 1
// 22
// 333
// 4444
// 55555
도움이 되었던 사이트들.
1. https://jaypedia.tistory.com/16
2. https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/repeat