Skip to content

Commit e55c16d

Browse files
committed
등수매기기 /기초
1 parent ac22d56 commit e55c16d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function solution(score) {
2+
// 각 학생의 평균 점수 계산
3+
const averages = score.map(([eng, math]) => (eng + math) / 2);
4+
5+
// 평균 점수를 내림차순으로 정렬하여 등수 매기기
6+
const sorted = [...averages].sort((a, b) => b - a);
7+
8+
// 원래 평균 점수 배열의 각 값이 정렬된 배열에서 몇 번째 순위인지 계산
9+
return averages.map((avg) => sorted.indexOf(avg) + 1);
10+
}

0 commit comments

Comments
 (0)