js/app.js
/**
 * Stores game result in local storage. Maximum of 3 records are stored.
 * Calls displayGameHistory method to display game history in popup section
 */
Stores game result in local storage. Maximum of 3 records are stored.
Calls displayGameHistory method to display game history in popup section
Stores game result in local storage . Maximum of 3 records are stored . Calls displayGameHistory method to display game history in popup section
function storeInLocalStorage() {
    let gameHistory = [];
    if (localStorage.history) {
        gameHistory = JSON.parse(localStorage.history);
    }
    gameHistory.push({
        timeTaken: timerHolder.textContent,
        totalMoves: movesHolder.textContent,
        starsEarned: starsHolder.outerHTML
    });
    if (gameHistory.length > 3) {
        gameHistory.shift();
    }
    localStorage.history = JSON.stringify(gameHistory);
    displayGameHistory();
}
function storeInLocalStorage ( ) { let gameHistory = [ ] ; if ( localStorage . history ) { gameHistory = JSON . parse ( localStorage . history ) ; } gameHistory . push ( { timeTaken : timerHolder . textContent , totalMoves : movesHolder . textContent , starsEarned : starsHolder . outerHTML } ) ; if ( gameHistory . length > 3 ) { gameHistory . shift ( ) ; } localStorage . history = JSON . stringify ( gameHistory ) ; displayGameHistory ( ) ; }
Stores game result in local storage.
Stores game result in local storage .
//Keep not more than 3 records for the Game history section //Remove first record