# JavaScript for small business: a quote calculator, due-date reminders and API data

> A free one-page JavaScript cheat sheet: find page elements, write a price rule, add days to dates and fetch API data into a table.

Source: https://learn.ynteractive.com/content/cheat-sheets/javascript-small-business · Updated 2026-10-24 · Free from Stepthrough (https://learn.ynteractive.com)

[Lesson cheat sheet](https://learn.ynteractive.com/content/cheat-sheets#kind-lesson) · One page · US letter · [JSFiddle](https://learn.ynteractive.com/content/tool/jsfiddle)

By [Robert Breen](https://learn.ynteractive.com/content/about) · Published October 24, 2026 · From the free lesson [JavaScript: An Instant Quote Calculator for Your Website](https://learn.ynteractive.com/content/js-quote-calculator)

A free one-page JavaScript cheat sheet: find page elements, write a price rule, add days to dates and fetch API data into a table.

[Download the free PDF (82 KB)](https://learn.ynteractive.com/content/cheat-sheets/javascript-small-business.pdf)Print this sheet

Free, no sign-up and no email needed. It prints on one letter-size page; the whole sheet is below.

*▶*StepthroughFree printable cheat sheet · learn.ynteractive.com

JavaScript for small business: a quote calculator, due-date reminders and API data

The three modules of the free JavaScript for Small Business Jump Start, practised there on real JSFiddle screens.

## Page parts and a click

**Find**

`document.querySelector('#sqft')` finds the element with id="sqft".

**Read**

`Number(box.value)` turns what was typed into a number.

**Write**

`result.textContent = 'Estimate: $' + price.toFixed(2);`

**Click**

`button.onclick = () => { ... };` runs on every click.

## A price rule with a minimum

1. `const RATE = 0.12;` and `const MINIMUM = 150;` at the top.
2. `function quote(sqft) { return Math.max(sqft * RATE, MINIMUM); }`
3. Math.max picks the bigger number: small jobs pay the minimum.

## Due dates

1. `const d = new Date(issued + 'T00:00');`
2. `d.setDate(d.getDate() + 30);` adds 30 days (Net 30).
3. `Math.round((due - today) / 86400000)` days left; below 0 is overdue.
4. At work use `const today = new Date();`

## Data from an API

1. `const response = await fetch(url);`
2. `const users = await response.json();` inside an async function.
3. `for (const u of users) { ... u.company.name ... }` one row each.

## Good habits

- Give every element you use an id.
- Keep business numbers in const lines at the top.
- Click the tidy icon in JSFiddle to indent your code.
- Never put a real API key in a public page or fiddle.

**Remember:** Put the business rule in one place and let the page do the arithmetic: one edit changes every quote, date and table.

Practice it free: [JavaScript: An Instant Quote Calculator for Your Website](https://learn.ynteractive.com/modules/js-quote-calculator) at learn.ynteractive.com/modules/js-quote-calculator. This sheet: learn.ynteractive.com/content/cheat-sheets/javascript-small-business. Brightway Office Cleaning and Northgate Bookkeeping is a made-up business from the lesson. By Robert Breen, October 24, 2026.

## Practice it in the free lesson

**JavaScript: An Instant Quote Calculator for Your Website**. A beginner JavaScript walkthrough in the free JSFiddle: a four-line HTML form and a few lines of JavaScript that turn square feet into a price, with a minimum charge, typed and run by you. You do every step yourself in a practice copy of JSFiddle, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.

[Start the free lesson](https://learn.ynteractive.com/modules/js-quote-calculator)

[Or read the full step-by-step guide](https://learn.ynteractive.com/content/js-quote-calculator)

## Lessons on this sheet

- [JavaScript: An Instant Quote Calculator for Your Website](https://learn.ynteractive.com/content/js-quote-calculator): A beginner JavaScript walkthrough in the free JSFiddle: a four-line HTML form and a few lines of JavaScript that turn square feet into a price, with a minimum charge…
- [JavaScript: Turn Invoice Dates into Due-Date Reminders](https://learn.ynteractive.com/content/js-due-date-reminders): A beginner JavaScript walkthrough in the free JSFiddle: work out Net 30 due dates, count the days left and list every invoice as due or overdue, typing every line…
- [JavaScript: Pull Contacts from an API into a Table](https://learn.ynteractive.com/content/js-api-contacts-table): A beginner JavaScript walkthrough in the free JSFiddle: fetch contact data from a free practice API and show name, company and email in a table, typing every line…

## Related terms

Plain-English definitions, each with an example from a free lesson.

[JavaScript](https://learn.ynteractive.com/content/glossary/javascript) · [fetch (JavaScript)](https://learn.ynteractive.com/content/glossary/fetch-api) · [API endpoint](https://learn.ynteractive.com/content/glossary/api-endpoint)

[The full AI glossary](https://learn.ynteractive.com/content/glossary)

## More cheat sheets

- [AI Email Responder in n8n Cheat Sheet](https://learn.ynteractive.com/content/cheat-sheets/ai-email-responder-n8n): A free one-page cheat sheet: n8n watches Gmail, an AI agent reads each customer email and saves a reply as a draft in the same thread.
- [AI Receipt Extractor in n8n Cheat Sheet](https://learn.ynteractive.com/content/cheat-sheets/receipt-extraction-setup): A free one-page cheat sheet: attach a receipt photo in n8n chat, and an AI agent pulls the date, vendor and amount into a Google Sheets row.
- [ChatGPT Bank Reconciliation Cheat Sheet](https://learn.ynteractive.com/content/cheat-sheets/chatgpt-bank-reconciliation): A free one-page cheat sheet: match a bank statement CSV to the ledger with ChatGPT, list the exceptions, build the summary and check the math yourself.

[All free cheat sheets](https://learn.ynteractive.com/content/cheat-sheets) · [All free tutorials](https://learn.ynteractive.com/content)
