Gdzie nocą tupta jeż?

Otwórz w trybie kompatybilności.

Kod

<!-- sekcja -> napis, button (pokaż podopwiedz) -> sekcja 2 z podpowiedź -> sama się usunie -->
<!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
</head>
<body>
    <section>
        <p>Gdzie nocą tupta jeż?</p>
        <button id="button">podpowiedź</button>
        <p id="timer"></p>
        <p id="podpowiedz"></p>
    </section>
    <script>
        let button = document.getElementById('button')
        let timer = document.getElementById('timer')
        let podpowiedz = document.getElementById('podpowiedz')
        let x = 5
        button.addEventListener('click',() => {
            x=5
            let newSection = document.createElement('section')
            newSection.innerText = 'Jest tam numer 19'
            podpowiedz.appendChild(newSection)
            setTimeout((()=>{
                timer.innerText =" "
                newSection.remove()
            }), 5000);
            timerFun()
        })
        function timerFun() {
            if (x!==0){
                timer.innerText = x
                x--
                setTimeout(timerFun, 1000);
            }
        }
    </script>
</body>
</html>