[์๊ณ ๋ฆฌ์ฆ || ํ๋ก๊ทธ๋๋จธ์ค] ํคํจ๋ ๋๋ฅด๊ธฐ, ์ ๊ท์ test() ํจ์ (feat.๋น๋๋์ ์ฝ๋๋ฆฌ๋ทฐ)
์ค๋๋ ํ ์ ์๋ ๊ฒ๋ค์ ์์๋๋ก ๋จผ์ ๋์ดํด๋ดค๋ค. function solution(numbers, hand) { const click = []; const keypad = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ['*', 0, '#'] ] const findKey = (n) => { let result = []; keypad.forEach((line, i) => { if (line.findIndex(v => v === n) !== -1) { result = [i, line.findIndex(v => v === n)]; return; } }) return result; } let [leftNow, rightNow] = [[3, 0], [3, 2]]; numbers.forEach(..