function solution(score) {
let average = score.map(num => (num[0]+num[1])/2);
let sorted = average.slice().sort((a, b) => b - a);
return average.map(num => sorted.indexOf(num) + 1);
}
https://happygunja.tistory.com/285
const array = [1, 3, 5, 7, 9]
array.splice(2, 1) // [5]
console.log(array) // [1, 3, 7, 9]
array.slice(0, 2) // [1, 3]
console.log(array) // [1, 3, 7, 9]
const array = [4, 2, 3, 1]
array.slice().sort((a, b) => a - b); // [1, 2, 3, 4]
console.log(array) // [4, 2, 3, 1]
function solution(score) {
return score.map((el) => {
return (
score.filter((v) => (v[0] + v[1]) / 2 > (el[0] + el[1]) / 2).length + 1
);
});
}