Skip to content

Commit 56cfd98

Browse files
committed
Update 220425 모의고사.js
1 parent 0d27d7f commit 56cfd98

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

level-1/모의고사.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,28 @@ function solution(answers) {
8181

8282
return answer;
8383
}
84+
85+
//정답 4 - jaewon1676
86+
function solution(answers) {
87+
let arr1 = [1,2,3,4,5]
88+
let arr2 = [2,1,2,3,2,4,2,5]
89+
let arr3 = [3,3,1,1,2,2,4,4,5,5]
90+
91+
let score = [0, 0, 0]
92+
for (let i=0; i<answers.length; i++){
93+
if (answers[i] === arr1[i%5]) {
94+
score[0] += 1;
95+
}
96+
if (answers[i] === arr2[i%8]) {
97+
score[1] += 1;
98+
}
99+
if (answers[i] === arr3[i%10]) {
100+
score[2] += 1;
101+
}
102+
}
103+
let answer = []
104+
for (let i=0; i<3; i++){
105+
if (score[i] === Math.max(...score)) answer.push(i+1)
106+
}
107+
return answer;
108+
}

0 commit comments

Comments
 (0)