처음 작성한 코드function solution(cards1, cards2, goal) { let answer = [true, true, true] console.log(answer.indexOf(false)) let arr = goal[0] == cards1[0] ? [...cards1].map((x,i) => cards1[i] === goal[i]) : [...cards2].map((x,i) => cards2[i] === goal[i]) let target = arr.indexOf(false) if (target === -1) { target = arr.length } let temp = goal[0] == cards1[0] ? [...cards1] ..