function gameOver() {
    for (var i = 0; i< displayType.length; i++) {
        $(displayType[i]).hide()
    } 
    
    $(scoreButton).show()
    //getting stored high scores and adding score 
    var storedHighScores = JSON.parse(localStorage.getItem('highscore'))
    console.log('high score' ,storedHighScores)
    var playerName = prompt('Please Enter your name', 'Name')
    if (playerName === !null) {
        storedHighScores.push([userScore.lastGame, playerName])
        localStorage.setItem('highscore', JSON.stringify(storedHighScores))
    }
    

    lastGameScore = userScore.lastGame
    localStorage.setItem('last-game', lastGameScore)
    userScore.totalScore = Number(userScore.totalScore) + Number(lastGameScore)

    var displayScoreLast = document.createElement('h2')
    var displayScoreTotal = document.createElement('h2')
    var displayScoreHighScore = document.createElement('h2')

    displayScoreLast.textContent = 'Score last game: ' + userScore.lastGame
    displayScoreTotal.textContent = 'Total score: ' + userScore.totalScore

    showScoreEl.setAttribute('style', 'display: flex; justify-Content: center; align-items: center')
    var displayScores = [displayScoreLast, displayScoreTotal, displayScoreHighScore]
    for (var j=0; j<displayScores.length; j++) {
        displayScores[j].setAttribute('style', 'background: darkgrey; color: gold; margin: 10px; padding; 10px')
    }
    
    showScoreEl.appendChild(displayScoreLast)
    showScoreEl.appendChild(displayScoreTotal)
    showScoreEl.appendChild(displayScoreHighScore)

    userScore.lastGame = 0
    playAgain(displayScoreLast,displayScoreTotal,displayScoreHighScore)
}
// the game over function shows the scores of the game
the game over function shows the scores of the game
the game over function shows the scores of the game
function gameOver() {
    for (var i = 0; i< displayType.length; i++) {
        $(displayType[i]).hide()
    } 
    $(scoreButton).show()
    var storedHighScores = JSON.parse(localStorage.getItem('highscore'))
    console.log('high score' ,storedHighScores)
    var playerName = prompt('Please Enter your name', 'Name')
    if (playerName === !null) {
        storedHighScores.push([userScore.lastGame, playerName])
        localStorage.setItem('highscore', JSON.stringify(storedHighScores))
    }
    lastGameScore = userScore.lastGame
    localStorage.setItem('last-game', lastGameScore)
    userScore.totalScore = Number(userScore.totalScore) + Number(lastGameScore)
    var displayScoreLast = document.createElement('h2')
    var displayScoreTotal = document.createElement('h2')
    var displayScoreHighScore = document.createElement('h2')
    displayScoreLast.textContent = 'Score last game: ' + userScore.lastGame
    displayScoreTotal.textContent = 'Total score: ' + userScore.totalScore
    showScoreEl.setAttribute('style', 'display: flex; justify-Content: center; align-items: center')
    var displayScores = [displayScoreLast, displayScoreTotal, displayScoreHighScore]
    for (var j=0; j<displayScores.length; j++) {
        displayScores[j].setAttribute('style', 'background: darkgrey; color: gold; margin: 10px; padding; 10px')
    }
    showScoreEl.appendChild(displayScoreLast)
    showScoreEl.appendChild(displayScoreTotal)
    showScoreEl.appendChild(displayScoreHighScore)
    userScore.lastGame = 0
    playAgain(displayScoreLast,displayScoreTotal,displayScoreHighScore)
}
function gameOver ( ) { for ( var i = 0 ; i < displayType . length ; i ++ ) { $ ( displayType [ i ] ) . hide ( ) } $ ( scoreButton ) . show ( ) var storedHighScores = JSON . parse ( localStorage . getItem ( 'highscore' ) ) console . log ( 'high score' , storedHighScores ) var playerName = prompt ( 'Please Enter your name' , 'Name' ) if ( playerName === ! null ) { storedHighScores . push ( [ userScore . lastGame , playerName ] ) localStorage . setItem ( 'highscore' , JSON . stringify ( storedHighScores ) ) } lastGameScore = userScore . lastGame localStorage . setItem ( 'last-game' , lastGameScore ) userScore . totalScore = Number ( userScore . totalScore ) + Number ( lastGameScore ) var displayScoreLast = document . createElement ( 'h2' ) var displayScoreTotal = document . createElement ( 'h2' ) var displayScoreHighScore = document . createElement ( 'h2' ) displayScoreLast . textContent = 'Score last game: ' + userScore . lastGame displayScoreTotal . textContent = 'Total score: ' + userScore . totalScore showScoreEl . setAttribute ( 'style' , 'display: flex; justify-Content: center; align-items: center' ) var displayScores = [ displayScoreLast , displayScoreTotal , displayScoreHighScore ] for ( var j = 0 ; j < displayScores . length ; j ++ ) { displayScores [ j ] . setAttribute ( 'style' , 'background: darkgrey; color: gold; margin: 10px; padding; 10px' ) } showScoreEl . appendChild ( displayScoreLast ) showScoreEl . appendChild ( displayScoreTotal ) showScoreEl . appendChild ( displayScoreHighScore ) userScore . lastGame = 0 playAgain ( displayScoreLast , displayScoreTotal , displayScoreHighScore ) }
the game over function shows the scores of the game
the game over function shows the scores of the game
//getting stored high scores and adding score 