Details

  1. Clicks counter should start from 0

  2. Every click on the incrementCounterButton should increase the click counter by 1

  3. A click on resetCounterButton should reset the click counter to 0

these are the task's demands

<!DOCTYPE html>
<html>

<head>
    <title>CoderslangJS click counter</title>
    <script defer>
        // The counter logic should be implemented right here!

        const handleButtonClick = () => {
            let p = document.getElementById('clicks');
            let count = Number(p.innerText);
            count += 1;
            p.innerHTML = String(count);

        }
        const resetCounter = () => {
            let p = document.getElementById('clicks');
            p.innerHTML = '0';
        }
        document.getElementById('incrementCounterButton').addEventListener('click', handleButtonClick);
        document.getElementById('resetCounterButton').addEventListener('click', resetCounter);
    </script>
</head>

<body>
    <h3>CLICKS:</h3>
    <p id="clicks">0</p>
    <button type="button" id="incrementCounterButton" onClick="handleButtonClick()">Click me</button>
    <button type="button" id="resetCounterButton" onClick="resetCounter()">Reset</button>
</body>

</html>

and this is my code, it works as demands
but when i submit, the second demand is saying incorrect
😞😞

    Write a Reply...