-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.가위바위보.html
43 lines (40 loc) · 1.03 KB
/
3.가위바위보.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<meta charset="UTF-8" />
<title>출력결과</title>
</head>
<body>
<script>
function solution(a, b) {
let answer = '';
a.forEach((ele, index) => {
if (a[index] === b[index]) {
answer = answer + 'D ';
}
if (a[index] === 1 && b[index] === 2) {
answer = answer + 'B ';
}
if (a[index] === 1 && b[index] === 3) {
answer = answer + 'A ';
}
if (a[index] === 2 && b[index] === 1) {
answer = answer + 'A ';
}
if (a[index] === 2 && b[index] === 3) {
answer = answer + 'B ';
}
if (a[index] === 3 && b[index] === 1) {
answer = answer + 'B ';
}
if (a[index] === 3 && b[index] === 2) {
answer = answer + ' A';
}
});
return answer;
}
let a = [2, 3, 3, 1, 3];
let b = [1, 1, 2, 2, 3];
console.log(solution(a, b));
</script>
</body>
</html>