JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./index.css">
    <title>Document</title>
</head>

<body>
    simple counter:
    <button onclick="substraction()">-</button>
    <button onclick="plus()">+</button>

    <hr>

    simple calculator:
    <input type="number" id="num2" />
    <input type="number" id="num3" />
    <button onclick="cal()">加/減/乘/除</button>
    <script src="./index.js"></script>
</body>

</html>

JavaScript

let num1 = 0;

function plus() {
    num1 += 1
    alert(num1);
}

function substraction() {
    num1 -= 1
    alert(num1);
}

function cal() {
    let num2 = Number(document.querySelector('#num2').value);
    let num3 = Number(document.querySelector('#num3').value);
    let cal1 = num2 + num3;
    let cal2 = num2 - num3;
    let cal3 = num2 * num3;
    let cal4 = num2 / num3;
    alert(cal1);
    alert(cal2);
    alert(cal3);
    alert(cal4);
}