작성
·
214
1
<html>
<head>
<meta charset="UTF-8" />
<title>출력결과</title>
</head>
<body>
<script>
function solution(a, b) {
let answer = [];
for (let i = 0; i < a.length; i++) {
if (a[i] === b[i]) answer.push('D');
else if (a[i] - b[i] === 1 || a[i] - b[i] === -2) answer.push('A');
else answer.push('B');
}
return answer;
}
let a = [2, 3, 3, 1, 3];
let b = [1, 1, 2, 2, 3];
console.log(solution(a, b));
</script>
</body>
</html>