Instructions
Manage a game player’s High Score list.
Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.
Our Solution
export class HighScores {
constructor(scores) {
this.scores = scores;
}
get latest() {
return this.scores[this.scores.length - 1];
}
get personalBest() {
return Math.max(...this.scores);
}
get personalTopThree() {
return [...this.scores].sort((a, b) => b - a).slice(0, 3);
}
}
Source: Exercism javascript/high-scores