function solution(answers) {
let answer = [];
let student1 = [1, 2, 3, 4, 5];
let student2 = [2, 1, 2, 3, 2, 4, 2, 5];
let student3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5];
let student1Count = answers.filter((a,i)=> a === student1[i%student1.length]).length;
let student2Count = answers.filter((a,i)=> a === student2[i%student2.length]).length;
let student3Count = answers.filter((a,i)=> a === student3[i%student3.length]).length;
let max = Math.max(student1Count,student2Count,student3Count);
if (student1Count === max) {
answer.push(1)
};
if (student2Count === max) {
answer.push(2)
};
if (student3Count === max) {
answer.push(3)
};
return answer;
}
https://velog.io/@ge-um/%EB%AA%A8%EC%9D%98%EA%B3%A0%EC%82%AC