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
};

Quiz App Master/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
};

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ In this video, we will create the Game Page and display static question and answ
4848

4949
## 3. Display Hard Coded Question and Answers
5050

51-
In this video, we will load questions from a hard coded array and iterate through available questions as the use answers them. We will use custom data attributes, the ES6 spread operator, and JavaScript arrow functions.
51+
In this video, we will load questions from a hard coded array and iterate through available questions as the user answers them. We will use custom data attributes, the ES6 spread operator, and JavaScript arrow functions.
5252

5353
Resources
5454

0 commit comments

Comments
 (0)