I'm a beginner in JavaScript and I decided to use an app to help me learn the language. In my index.html file, I have included the following code:
<div data-role="collapsible">
<h3>Reset Score</h3>
<button type="button" id="resetscore">Reset</button>
<script type="text/javascript">
function reset() {
localStorage.setItem('total_win', 0);
localStorage.setItem('total_lose', 0);
}
</script>
</div>
And as part of the footer, I added:
`<div id="scores" class="ui-grid-b">
<div class="ui-block-a">Tries left:<span id="tries_left">4</span></div>
<div class="ui-block-b">Total win:<span id="total_win">0</span></div>
<div class="ui-block-c">Total lost:<span id="total_lose">0</span></div>
</div>`
Despite my efforts, I am unable to reset the score back to zero. Even adding alert() statements inside the reset() function did not solve the issue.
If anyone has any insights on why this could be happening, I would greatly appreciate your help! Thank you!