-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhighscores.js
More file actions
17 lines (16 loc) · 875 Bytes
/
Copy pathhighscores.js
File metadata and controls
17 lines (16 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const highScoresList = document.getElementById('highScoresList')
// Get the high scores from the local storage
const highScores = JSON.parse(localStorage.getItem('highScores')) || []
// Add each scores in the unordered list (li)
highScoresList.innerHTML = highScores.map(score => {
if (score.score > 90) {
return `<ul style="list-style-image: url(/chickuiz/assets/fullHeadedChickenIcon.png)">
<li class="high-score">${score.name} - ${score.score} points</li></ul>`
} else if (score.score > 40) {
return `<ul style="list-style-image: url(/chickuiz/assets/happyChickIcon.png)">
<li class="high-score">${score.name} - ${score.score} points</li></ul>`
} else if (score.score >= 0) {
return `<ul style="list-style-image: url(/chickuiz/assets/noobEggIcon.png)">
<li class="high-score">${score.name} - ${score.score} points</li></ul>`
}
}).join('')