DEV Community

angelyn Muñoz
angelyn Muñoz

Posted on

How to program a cleaning price calculator with JavaScript

You know when you start a project that seems simple and suddenly you're like, “what did I get myself into?” Yeah… that happened to me with a cleaning price calculator.

A friend had a small business offering Window Cleaning Albany park and asked me for a “quick calculator” on his website.

I thought: “A few lines of JavaScript, done.” Spoiler: nope. But I learned a lot, and today I want to share how you can build a useful version without losing your mind.


Albany park

Context: Why a Calculator Like This?

Imagine this: you have a rental property, like an Airbnb. The client wants to know how much the cleaning will cost but hates sending emails.

So, boom: a small app that estimates the price instantly. No weird forms. No waiting.

If you're in the business of offering Cleaning Services Albany Park, this isn’t a luxury—it’s practically a necessity.


Key Concepts (Promise I Won’t Make It Boring)

These are the must-consider points if you're going to code a calculator:

  • Types and number of rooms
  • Level of mess (light, normal, disaster zone)
  • Extras like sheet laundry or oven cleaning
  • Base rates by city or area
  • Final sum with business logic

And you know what? All of that can live in a JS object.


Step-by-Step: Building Something Functional (and Not Ugly)

1. Define Your Base Rates and Extras

const basePrices = {
  bedroom: 25,
  bathroom: 30,
  kitchen: 35,
  living_room: 20
};

const addOns = {
  laundry: 15,
  oven_cleaning: 20,
  inside_fridge: 18
};
Enter fullscreen mode Exit fullscreen mode

Nothing crazy—just a plain object. Easy to scale.

2. Let the User Choose Their Property Type

const formInput = {
  bedrooms: 2,
  bathrooms: 1,
  kitchen: true,
  living_room: true,
  extras: ['laundry', 'oven_cleaning']
};
Enter fullscreen mode Exit fullscreen mode

With that alone, you can start calculating values.

3. Calculate the Total Based on the Input

function calculateTotal(input) {
  let total = 0;
  total += input.bedrooms * basePrices.bedroom;
  total += input.bathrooms * basePrices.bathroom;
  if (input.kitchen) total += basePrices.kitchen;
  if (input.living_room) total += basePrices.living_room;

  input.extras.forEach(extra => {
    total += addOns[extra] || 0;
  });

  return total;
}

const finalPrice = calculateTotal(formInput);
console.log(`Total: $${finalPrice}`);
Enter fullscreen mode Exit fullscreen mode

Simple, right? But powerful. You can display it live with innerText in your HTML and you’ve got something that feels magical.


Small Details That Improve UX

  • If someone books a cleaning on a Sunday, add a 10% surcharge.
  • If the property is outside your normal radius, add a travel fee.
  • And in cities like Chicago, adjust for the zone (urban vs. suburban rates).

This is where real customization comes in if you’re selling Residential And Commercial Cleaning in Albany park.

Good UX can make people trust your quote.


Reader Benefits (Real Talk)

If you do this right, you’ll notice:

  • Fewer questions from clients (less back-and-forth!)
  • You save 20 minutes per quote
  • You charge fairly without losing money
  • You start to look more professional, more trustworthy

And that’s worth more than any overpriced plugin.


Final Thoughts: Don’t Overthink It

It took me longer to write this post than to code the first version of the calculator.

Perfect? Nope.

Useful? Totally.

Replaceable by something more pro later? Sure.

But if you're starting out or need something NOW, this works.

Give it a try this week. Upload it, test it, show it to a client. You’ll see the difference.

And if you end up building something more complex, drop me the link. I’d love to see it in action 😄

Top comments (0)