diff --git a/10. Fetch Questions from Local JSON File/end.js b/10. Fetch Questions from Local JSON File/end.js index e8eda3a..8e417b1 100644 --- a/10. Fetch Questions from Local JSON File/end.js +++ b/10. Fetch Questions from Local JSON File/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/11. Fetch API Questions from Open Trivia API/end.js b/11. Fetch API Questions from Open Trivia API/end.js index e8eda3a..8e417b1 100644 --- a/11. Fetch API Questions from Open Trivia API/end.js +++ b/11. Fetch API Questions from Open Trivia API/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/12. Create a Spinning Loader/end.js b/12. Create a Spinning Loader/end.js index e8eda3a..8e417b1 100644 --- a/12. Create a Spinning Loader/end.js +++ b/12. Create a Spinning Loader/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/4. Display Feedback for Correct:Incorrect Answers/app.css b/4. Display Feedback for Correct and Incorrect Answers/app.css similarity index 100% rename from 4. Display Feedback for Correct:Incorrect Answers/app.css rename to 4. Display Feedback for Correct and Incorrect Answers/app.css diff --git a/4. Display Feedback for Correct:Incorrect Answers/game.css b/4. Display Feedback for Correct and Incorrect Answers/game.css similarity index 100% rename from 4. Display Feedback for Correct:Incorrect Answers/game.css rename to 4. Display Feedback for Correct and Incorrect Answers/game.css diff --git a/4. Display Feedback for Correct:Incorrect Answers/game.html b/4. Display Feedback for Correct and Incorrect Answers/game.html similarity index 100% rename from 4. Display Feedback for Correct:Incorrect Answers/game.html rename to 4. Display Feedback for Correct and Incorrect Answers/game.html diff --git a/4. Display Feedback for Correct:Incorrect Answers/game.js b/4. Display Feedback for Correct and Incorrect Answers/game.js similarity index 100% rename from 4. Display Feedback for Correct:Incorrect Answers/game.js rename to 4. Display Feedback for Correct and Incorrect Answers/game.js diff --git a/4. Display Feedback for Correct:Incorrect Answers/index.html b/4. Display Feedback for Correct and Incorrect Answers/index.html similarity index 100% rename from 4. Display Feedback for Correct:Incorrect Answers/index.html rename to 4. Display Feedback for Correct and Incorrect Answers/index.html diff --git a/8. Save High Scores in Local Storage/end.js b/8. Save High Scores in Local Storage/end.js index e8eda3a..8e417b1 100644 --- a/8. Save High Scores in Local Storage/end.js +++ b/8. Save High Scores in Local Storage/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/9. Load and Display High Scores from Local Storage/end.js b/9. Load and Display High Scores from Local Storage/end.js index e8eda3a..8e417b1 100644 --- a/9. Load and Display High Scores from Local Storage/end.js +++ b/9. Load and Display High Scores from Local Storage/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/Quiz App Master/end.js b/Quiz App Master/end.js index e8eda3a..8e417b1 100644 --- a/Quiz App Master/end.js +++ b/Quiz App Master/end.js @@ -1,30 +1,30 @@ -const username = document.getElementById("username"); -const saveScoreBtn = document.getElementById("saveScoreBtn"); -const finalScore = document.getElementById("finalScore"); -const mostRecentScore = localStorage.getItem("mostRecentScore"); +const username = document.getElementById('username'); +const saveScoreBtn = document.getElementById('saveScoreBtn'); +const finalScore = document.getElementById('finalScore'); +const mostRecentScore = localStorage.getItem('mostRecentScore'); -const highScores = JSON.parse(localStorage.getItem("highScores")) || []; +const highScores = JSON.parse(localStorage.getItem('highScores')) || []; const MAX_HIGH_SCORES = 5; finalScore.innerText = mostRecentScore; -username.addEventListener("keyup", () => { - saveScoreBtn.disabled = !username.value; +username.addEventListener('keyup', () => { + saveScoreBtn.disabled = !username.value; }); -saveHighScore = e => { - console.log("clicked the save button!"); - e.preventDefault(); +saveHighScore = (e) => { + console.log('clicked the save button!'); + e.preventDefault(); - const score = { - score: Math.floor(Math.random() * 100), - name: username.value - }; - highScores.push(score); - highScores.sort((a, b) => b.score - a.score); - highScores.splice(5); + const score = { + score: mostRecentScore, + name: username.value, + }; + highScores.push(score); + highScores.sort((a, b) => b.score - a.score); + highScores.splice(5); - localStorage.setItem("highScores", JSON.stringify(highScores)); - window.location.assign("/"); + localStorage.setItem('highScores', JSON.stringify(highScores)); + window.location.assign('/'); }; diff --git a/ReadMe.md b/ReadMe.md index 4202d0d..25b1f26 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -48,7 +48,7 @@ In this video, we will create the Game Page and display static question and answ ## 3. Display Hard Coded Question and Answers -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. +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. Resources