-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
졸업선물 화살표함수 질문
22.07.11 21:59 작성 조회수 104
0
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
function solution(m, product){
let answer=0;
n=product.length;
product.sort((a, b)=>(a[0]+a[1])-(b[0]+b[1]));
// console.log(product);
for(let i=0; i<n; i++){
let money=m
}
return answer;
}
let arr = [[6,6], [2,2], [4,3], [4,5], [10,3]];
console.log(solution(28, arr));
</script>
</body>
</html>
이 코드에서 product.sort((a, b)=>(a[0]+a[1])-(b[0]+b[1])); 가 잘 이해되지 않습니다. (a[0]+a[1])-(b[0]+b[1])빼주면 왜 sort함수에 의해 정렬이 되는지 궁금합니다.
답변을 작성해보세요.
1
답변 1