Hi there, just working on a quiz and my question is, below in the code, it mentions “localstorage”, I take it that is where the entries are stored.
1/ Where exactly are they stored?
2/is it a file I can edit?
At this stage I have no idea where the entries (highscores) are stored.
It must be a file somewhere as they are shown in another file that has:
<ul id="highScoresList" class="q-ul-list"></ul>
In it, I understand they are stored as list items but WHERE???
I have some test entries I would like to delete, hence me wanting to edit the entries.
Another question is: Is it possible to store the entries in a given file, like "entries.inc "?
PS: I got the code off a YouTube video.
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 MAX_HIGH_SCORES = 1000;
finalScore.innerText = mostRecentScore;
username.addEventListener('keyup', () => {
saveScoreBtn.disabled = !username.value;
});
saveHighScore = (e) => {
e.preventDefault();
const score = {
score: mostRecentScore,
name: username.value,
};
highScores.push(score);
highScores.sort((a, b) => b.score - a.score);
highScores.splice(1000);
localStorage.setItem('highScores', JSON.stringify(highScores));
window.location.assign('index.html');
};