Skip to content

Commit 4b66bcd

Browse files
committed
2 parents bc235d4 + 70a7115 commit 4b66bcd

File tree

12 files changed

+115
-115
lines changed

12 files changed

+115
-115
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const username = document.getElementById("username");
2-
const saveScoreBtn = document.getElementById("saveScoreBtn");
3-
const finalScore = document.getElementById("finalScore");
4-
const mostRecentScore = localStorage.getItem("mostRecentScore");
1+
const username = document.getElementById('username');
2+
const saveScoreBtn = document.getElementById('saveScoreBtn');
3+
const finalScore = document.getElementById('finalScore');
4+
const mostRecentScore = localStorage.getItem('mostRecentScore');
55

6-
const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
6+
const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
77

88
const MAX_HIGH_SCORES = 5;
99

1010
finalScore.innerText = mostRecentScore;
1111

12-
username.addEventListener("keyup", () => {
13-
saveScoreBtn.disabled = !username.value;
12+
username.addEventListener('keyup', () => {
13+
saveScoreBtn.disabled = !username.value;
1414
});
1515

16-
saveHighScore = e => {
17-
console.log("clicked the save button!");
18-
e.preventDefault();
16+
saveHighScore = (e) => {
17+
console.log('clicked the save button!');
18+
e.preventDefault();
1919

20-
const score = {
21-
score: Math.floor(Math.random() * 100),
22-
name: username.value
23-
};
24-
highScores.push(score);
25-
highScores.sort((a, b) => b.score - a.score);
26-
highScores.splice(5);
20+
const score = {
21+
score: mostRecentScore,
22+
name: username.value,
23+
};
24+
highScores.push(score);
25+
highScores.sort((a, b) => b.score - a.score);
26+
highScores.splice(5);
2727

28-
localStorage.setItem("highScores", JSON.stringify(highScores));
29-
window.location.assign("/");
28+
localStorage.setItem('highScores', JSON.stringify(highScores));
29+
window.location.assign('/');
3030
};
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const username = document.getElementById("username");
2-
const saveScoreBtn = document.getElementById("saveScoreBtn");
3-
const finalScore = document.getElementById("finalScore");
4-
const mostRecentScore = localStorage.getItem("mostRecentScore");
1+
const username = document.getElementById('username');
2+
const saveScoreBtn = document.getElementById('saveScoreBtn');
3+
const finalScore = document.getElementById('finalScore');
4+
const mostRecentScore = localStorage.getItem('mostRecentScore');
55

6-
const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
6+
const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
77

88
const MAX_HIGH_SCORES = 5;
99

1010
finalScore.innerText = mostRecentScore;
1111

12-
username.addEventListener("keyup", () => {
13-
saveScoreBtn.disabled = !username.value;
12+
username.addEventListener('keyup', () => {
13+
saveScoreBtn.disabled = !username.value;
1414
});
1515

16-
saveHighScore = e => {
17-
console.log("clicked the save button!");
18-
e.preventDefault();
16+
saveHighScore = (e) => {
17+
console.log('clicked the save button!');
18+
e.preventDefault();
1919

20-
const score = {
21-
score: Math.floor(Math.random() * 100),
22-
name: username.value
23-
};
24-
highScores.push(score);
25-
highScores.sort((a, b) => b.score - a.score);
26-
highScores.splice(5);
20+
const score = {
21+
score: mostRecentScore,
22+
name: username.value,
23+
};
24+
highScores.push(score);
25+
highScores.sort((a, b) => b.score - a.score);
26+
highScores.splice(5);
2727

28-
localStorage.setItem("highScores", JSON.stringify(highScores));
29-
window.location.assign("/");
28+
localStorage.setItem('highScores', JSON.stringify(highScores));
29+
window.location.assign('/');
3030
};

12. Create a Spinning Loader/end.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const username = document.getElementById("username");
2-
const saveScoreBtn = document.getElementById("saveScoreBtn");
3-
const finalScore = document.getElementById("finalScore");
4-
const mostRecentScore = localStorage.getItem("mostRecentScore");
1+
const username = document.getElementById('username');
2+
const saveScoreBtn = document.getElementById('saveScoreBtn');
3+
const finalScore = document.getElementById('finalScore');
4+
const mostRecentScore = localStorage.getItem('mostRecentScore');
55

6-
const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
6+
const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
77

88
const MAX_HIGH_SCORES = 5;
99

1010
finalScore.innerText = mostRecentScore;
1111

12-
username.addEventListener("keyup", () => {
13-
saveScoreBtn.disabled = !username.value;
12+
username.addEventListener('keyup', () => {
13+
saveScoreBtn.disabled = !username.value;
1414
});
1515

16-
saveHighScore = e => {
17-
console.log("clicked the save button!");
18-
e.preventDefault();
16+
saveHighScore = (e) => {
17+
console.log('clicked the save button!');
18+
e.preventDefault();
1919

20-
const score = {
21-
score: Math.floor(Math.random() * 100),
22-
name: username.value
23-
};
24-
highScores.push(score);
25-
highScores.sort((a, b) => b.score - a.score);
26-
highScores.splice(5);
20+
const score = {
21+
score: mostRecentScore,
22+
name: username.value,
23+
};
24+
highScores.push(score);
25+
highScores.sort((a, b) => b.score - a.score);
26+
highScores.splice(5);
2727

28-
localStorage.setItem("highScores", JSON.stringify(highScores));
29-
window.location.assign("/");
28+
localStorage.setItem('highScores', JSON.stringify(highScores));
29+
window.location.assign('/');
3030
};
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const username = document.getElementById("username");
2-
const saveScoreBtn = document.getElementById("saveScoreBtn");
3-
const finalScore = document.getElementById("finalScore");
4-
const mostRecentScore = localStorage.getItem("mostRecentScore");
1+
const username = document.getElementById('username');
2+
const saveScoreBtn = document.getElementById('saveScoreBtn');
3+
const finalScore = document.getElementById('finalScore');
4+
const mostRecentScore = localStorage.getItem('mostRecentScore');
55

6-
const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
6+
const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
77

88
const MAX_HIGH_SCORES = 5;
99

1010
finalScore.innerText = mostRecentScore;
1111

12-
username.addEventListener("keyup", () => {
13-
saveScoreBtn.disabled = !username.value;
12+
username.addEventListener('keyup', () => {
13+
saveScoreBtn.disabled = !username.value;
1414
});
1515

16-
saveHighScore = e => {
17-
console.log("clicked the save button!");
18-
e.preventDefault();
16+
saveHighScore = (e) => {
17+
console.log('clicked the save button!');
18+
e.preventDefault();
1919

20-
const score = {
21-
score: Math.floor(Math.random() * 100),
22-
name: username.value
23-
};
24-
highScores.push(score);
25-
highScores.sort((a, b) => b.score - a.score);
26-
highScores.splice(5);
20+
const score = {
21+
score: mostRecentScore,
22+
name: username.value,
23+
};
24+
highScores.push(score);
25+
highScores.sort((a, b) => b.score - a.score);
26+
highScores.splice(5);
2727

28-
localStorage.setItem("highScores", JSON.stringify(highScores));
29-
window.location.assign("/");
28+
localStorage.setItem('highScores', JSON.stringify(highScores));
29+
window.location.assign('/');
3030
};
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const username = document.getElementById("username");
2-
const saveScoreBtn = document.getElementById("saveScoreBtn");
3-
const finalScore = document.getElementById("finalScore");
4-
const mostRecentScore = localStorage.getItem("mostRecentScore");
1+
const username = document.getElementById('username');
2+
const saveScoreBtn = document.getElementById('saveScoreBtn');
3+
const finalScore = document.getElementById('finalScore');
4+
const mostRecentScore = localStorage.getItem('mostRecentScore');
55

6-
const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
6+
const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
77

88
const MAX_HIGH_SCORES = 5;
99

1010
finalScore.innerText = mostRecentScore;
1111

12-
username.addEventListener("keyup", () => {
13-
saveScoreBtn.disabled = !username.value;
12+
username.addEventListener('keyup', () => {
13+
saveScoreBtn.disabled = !username.value;
1414
});
1515

16-
saveHighScore = e => {
17-
console.log("clicked the save button!");
18-
e.preventDefault();
16+
saveHighScore = (e) => {
17+
console.log('clicked the save button!');
18+
e.preventDefault();
1919

20-
const score = {
21-
score: Math.floor(Math.random() * 100),
22-
name: username.value
23-
};
24-
highScores.push(score);
25-
highScores.sort((a, b) => b.score - a.score);
26-
highScores.splice(5);
20+
const score = {
21+
score: mostRecentScore,
22+
name: username.value,
23+
};
24+
highScores.push(score);
25+
highScores.sort((a, b) => b.score - a.score);
26+
highScores.splice(5);
2727

28-
localStorage.setItem("highScores", JSON.stringify(highScores));
29-
window.location.assign("/");
28+
localStorage.setItem('highScores', JSON.stringify(highScores));
29+
window.location.assign('/');
3030
};

0 commit comments

Comments
 (0)