/**
* @param {number[]} score
* @return {string[]}
*/
var findRelativeRanks = function(score) {
const sortedArray = [...score].sort((a,b) => b-a);
let count = 1;
let obj = {};
for (let i = 0; i < sortedArray.length; i++) {
obj[sortedArray[i]] = getValue(count);
count++;
}
for(let i=0; i<score.length; i++){
score[i] = obj[score[i]]?.toString()
}
return score
};
const getValue = (count) =>{
switch(count){
case 1:
return "Gold Medal";
case 2:
return "Silver Medal";
case 3:
return "Bronze Medal"
default:
return count;
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)