Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…App-With-HTML-CSS-and-JavaScript into pr/JayantDwivedi/9
  • Loading branch information
jamesqquick committed Jun 11, 2020
2 parents bc235d4 + 70a7115 commit 4b66bcd
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 115 deletions.
38 changes: 19 additions & 19 deletions 10. Fetch Questions from Local JSON File/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
38 changes: 19 additions & 19 deletions 11. Fetch API Questions from Open Trivia API/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
38 changes: 19 additions & 19 deletions 12. Create a Spinning Loader/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
38 changes: 19 additions & 19 deletions 8. Save High Scores in Local Storage/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
38 changes: 19 additions & 19 deletions 9. Load and Display High Scores from Local Storage/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
38 changes: 19 additions & 19 deletions Quiz App Master/end.js
Original file line number Diff line number Diff line change
@@ -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('/');
};
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4b66bcd

Please sign in to comment.