js/app.js
/**
 * Displays the game history in final modal. Game history is displayed chronologically in ascending order.
 */
Displays the game history in final modal. Game history is displayed chronologically in ascending order.
Displays the game history in final modal . Game history is displayed chronologically in ascending order .
function displayGameHistory() {
    const locallySavedData = JSON.parse(localStorage.history);
    const historyFragment = document.createDocumentFragment();
    locallySavedData.forEach(localData => {
        const trElement = document.createElement('tr');
        const tdElement1 = document.createElement('td');
        const tdElement2 = document.createElement('td');
        const tdElement3 = document.createElement('td');
        tdElement1.textContent = localData.timeTaken;
        tdElement2.textContent = localData.totalMoves;
        tdElement3.innerHTML = localData.starsEarned;
        trElement.appendChild(tdElement1);
        trElement.appendChild(tdElement2);
        trElement.appendChild(tdElement3);
        historyFragment.appendChild(trElement)
    });
    const tableBody = document.querySelector('tbody');
    tableBody.innerHTML = '';
    tableBody.appendChild(historyFragment);
}
function displayGameHistory ( ) { const locallySavedData = JSON . parse ( localStorage . history ) ; const historyFragment = document . createDocumentFragment ( ) ; locallySavedData . forEach ( localData => { const trElement = document . createElement ( 'tr' ) ; const tdElement1 = document . createElement ( 'td' ) ; const tdElement2 = document . createElement ( 'td' ) ; const tdElement3 = document . createElement ( 'td' ) ; tdElement1 . textContent = localData . timeTaken ; tdElement2 . textContent = localData . totalMoves ; tdElement3 . innerHTML = localData . starsEarned ; trElement . appendChild ( tdElement1 ) ; trElement . appendChild ( tdElement2 ) ; trElement . appendChild ( tdElement3 ) ; historyFragment . appendChild ( trElement ) } ) ; const tableBody = document . querySelector ( 'tbody' ) ; tableBody . innerHTML = '' ; tableBody . appendChild ( historyFragment ) ; }
Displays the game history in final modal.
Displays the game history in final modal .
//assign values