79249245

Date: 2024-12-03 21:45:42
Score: 0.5
Natty:
Report link

const display = document.getElementById("display");
const incrementButton = document.getElementById("increment");
const decrementButton = document.getElementById("decrement");
const resetButton = document.getElementById("reset");

let count = 0;

incrementButton.addEventListener("click", () => {
    count++;
    updateDisplay();
});

decrementButton.addEventListener("click", () => {
    count--;
    updateDisplay();
});

resetButton.addEventListener("click", () => {
    count = 0;
    updateDisplay();
});

function updateDisplay() {
    display.textContent = count;
}
body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f5f5f5;
}

.counter-container {
    text-align: center;
    background: #ffffff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-bottom: 20px;
    color: #333;
}

#display {
    font-size: 48px;
    margin-bottom: 20px;
    color: #333;
    font-weight: bold;
}

.buttons {
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 20px;
    font-size: 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button#increment {
    background-color: #4caf50;
    color: white;
}

button#decrement {
    background-color: #f44336;
    color: white;
}

button#reset {
    background-color: #2196f3;
    color: white;
}

button:hover {
    opacity: 0.8;
}
<div class="counter-container">
        <h1>Tally Counter</h1>
        <div id="display">0</div>
        <div class="buttons">
            <button id="increment">+1</button>
            <button id="decrement">-1</button>
            <button id="reset">Reset</button>
        </div>

    </div>

I got this script from github presented by suraheyaseen.com

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Aslam