Time for action – resuming a game from the local storage
Carry out the following steps:
Open the
matchgame.js
JavaScript file.In the jQuery document
ready
function, we used the saved order of the deck in the previous game instead of shuffling a new deck. Add the following highlighted code in the jQueryready
function:$(document).ready(function(){ // reset the elapsed time to 0. matchingGame.elapsedTime = 0; // start the timer matchingGame.timer = setInterval(countTimer, 1000); // shuffling the deck matchingGame.deck.sort(shuffle); // re-create the saved deck var savedObject = savedSavingObject(); if (savedObject !== undefined) { matchingGame.deck = savedObject.deck; } // copying the deck into saving object. matchingGame.savingObject.deck = matchingGame.deck.slice(); });
Still in the jQuery document
ready
function, we append the following highlighted code to the end of the function. It removes any card that was marked as removed in the saved data. We also restore...