A four-function calculator that runs as a static page, written in HTML, CSS and vanilla JavaScript. It has no build step and no runtime dependencies.
- Adds, subtracts, multiplies and divides two numbers. Results chain:
2 + 3 =, then* 4 =shows 20. - Accepts decimal numbers, with one decimal point per operand.
- Starts a new entry when a digit follows
=, and continues from the result when an operator follows=. - Replaces the operator when a second one is pressed, and keeps the first operand.
ACclears the display and the pending operation.- Divides by zero without a check, so the display shows
Infinity. - Takes input from button clicks only.
script.jshas no keyboard handler. - Uses a fixed 400 by 600 pixel box from
style.css. The layout does not change with the screen size.
index.html: the display and the 17 buttons.style.css: layout and colors.script.js: all calculator logic, started onDOMContentLoaded.favicon.svgandfavicon.png: browser tab icons.tests/calculator.test.mjs: seven tests that runscript.jsin a Node VM with a stub DOM.scripts/validate.mjs: checks the asset links, button values, JavaScript syntax and thatpackage.jsonlists no dependencies..github/: a GitHub Actions workflow and scripts for Renovate pull requests.
- A web browser to use the calculator.
- Node.js 24.20.0 or later for the checks, as set in
enginesinpackage.json.
Open index.html in a browser, or serve the folder with any static file server, for example npx serve ..
npm test # node --test tests/*.test.mjs
npm run validate # node scripts/validate.mjsNeither command installs anything, because the project has no dependencies and no lockfile.
The live site runs on a self-hosted Coolify server. Its build runs the tests and scripts/validate.mjs, copies index.html, script.js, style.css and the two favicons into build/, and nginx serves that folder.
GitHub Pages serves a second copy from the root of the main branch at https://t-scheiber.github.io/CalculatorApp/