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.
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
const RATE = 0.12;andconst MINIMUM = 150;at the top.function quote(sqft) { return Math.max(sqft * RATE, MINIMUM); }- Math.max picks the bigger number: small jobs pay the minimum.
Due dates
const d = new Date(issued + 'T00:00');d.setDate(d.getDate() + 30);adds 30 days (Net 30).Math.round((due - today) / 86400000)days left; below 0 is overdue.- At work use
const today = new Date();
Data from an API
const response = await fetch(url);const users = await response.json();inside an async function.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 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 lessonLessons on this sheet
JavaScript: An Instant Quote Calculator for Your WebsiteA 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…
Free · Live ~12 min Beginner
JavaScript: Turn Invoice Dates into Due-Date RemindersA 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…
Free · Live ~15 min Beginner
JavaScript: Pull Contacts from an API into a TableA 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…
Free · Live ~12 min Beginner
Related terms
Plain-English definitions, each with an example from a free lesson.
More cheat sheets
AI Email Responder in n8n Cheat SheetA 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.
Lesson cheat sheet Free PDF
AI Receipt Extractor in n8n Cheat SheetA 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.
Lesson cheat sheet Free PDF
ChatGPT Bank Reconciliation Cheat SheetA 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.
Lesson cheat sheet Free PDF