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">
    <style>
        #sekcjaTransation{
            background: burlywood;
            transition: height 1s;
        }
    </style>
</head>
<body>
    <section>
        Gdzie nocą tupta jeż?  <button id="button">podpowiedź</button>
        <p id="timer" style="margin: 1px; margin-bottom: 4px;"></p>
    </section>
    <script>
        let button = document.getElementById('button')
        let timer = document.getElementById('timer')
        let x = 5
        let czyIstnieje = false
        button.addEventListener('click', () => {
            if (czyIstnieje === false){
                let newSection = document.createElement('section')
                newSection.setAttribute('id','sekcja')
                newSection.setAttribute('class','sekcjaTransation')
                newSection.innerText = 'Jest tam numer 19'
                timer.appendChild(newSection)
                czyIstnieje = true
            }
            else if (czyIstnieje === true) {
                let sekcja = document.getElementById('sekcja')
                sekcja.remove()
                czyIstnieje = false
            }
            // setTimeout((() => {
            //     timer.innerText = ""
            // }), 5000);
            // timerFun()
        })
        // function timerFun() {
        //     if (x !== 0) {
        //         timer.innerText = x
        //         x--
        //         setTimeout(timerFun, 1000);
        //     }
        // }
    </script>
</body>
</html>