[javascript] reduce(), repeat()
1. reduce(callbackFn, initialValue) 2. repeat(count) function solution(heart, k) { let answer = []; heart.map((a) => { const expanded = [...a].reduce((acc, cur) => acc + cur.repeat(k), ''); for (let i = 0; i < k; i++) answer.push(expanded); }); return answer; } let heart = ['.oo...oo.', 'o..o.o..o', 'o...o...o', '.o.....o.', '..o...o..', '...o.o...', '....o....']; console.log('heart', heart); co..
2023. 8. 10.