# Building a Restaurant Menu Price Comparison Tool With JavaScript

Restaurant menu prices are a useful example of a real-world data problem. A menu item can have different prices depending on the location, ordering channel, and date the information was collected.

In this tutorial, we'll build a lightweight restaurant price comparison tool using vanilla JavaScript. We'll use Raising Cane's chicken finger combos as sample products, but the same approach works for other restaurants, retail catalogs, and local pricing datasets.

By the end, you'll understand how to structure pricing data, calculate differences, handle missing values, and build a simple interactive interface without a framework.

## 1\. Understanding the Data Problem

Imagine collecting prices for the same restaurant menu across three locations.

You want to answer three questions:

- Which location has the lowest recorded price?
- How much does a combo vary between locations?
- How can you avoid displaying outdated prices as current?

The challenge is that a price is not just a number. It needs context.

A useful record should include the product identifier, location, price, currency, collection date, and source.

## 2\. Create a JavaScript Pricing Dataset

We'll start with a small dataset.

All prices below are fictional examples for testing. They are not actual Raising Cane's restaurant prices.

```javascript
const menuPrices = [
  {
    item: "Box Combo",
    location: "Location A",
    price: 11.49,
    currency: "USD",
    checkedAt: "2026-11-01"
  },
  {
    item: "Box Combo",
    location: "Location B",
    price: 12.29,
    currency: "USD",
    checkedAt: "2026-11-01"
  },
  {
    item: "Box Combo",
    location: "Location C",
    price: 10.99,
    currency: "USD",
    checkedAt: "2026-11-01"
  }
];
```

Using objects instead of separate arrays makes the dataset easier to maintain. Each price stays connected to its location and collection date.

In a production application, you would also want a stable restaurant ID and item ID.

## 3\. Find the Lowest and Highest Prices

JavaScript's array methods make this straightforward.

```javascript
const prices = menuPrices
  .filter(row => Number.isFinite(row.price))
  .map(row => row.price);

if (prices.length === 0) {
  throw new Error("No valid prices available");
}

const lowest = Math.min(...prices);
const highest = Math.max(...prices);
const difference = highest - lowest;

console.log({
  lowest,
  highest,
  difference: Number(difference.toFixed(2))
});
```

The output for our sample dataset is:

```json
{
  "lowest": 10.99,
  "highest": 12.29,
  "difference": 1.30
}
```

This tells us the observed spread between locations, not whether a restaurant has increased its prices over time.

That distinction matters when building trustworthy comparison tools.

## 4\. Calculate Percentage Price Differences

A percentage comparison helps normalize differences between items at different price points.

```javascript
function percentageDifference(low, high) {
  if (
    !Number.isFinite(low) ||
    !Number.isFinite(high) ||
    low <= 0
  ) {
    return null;
  }

  return ((high - low) / low) * 100;
}

const result = percentageDifference(10.99, 12.29);

console.log(result.toFixed(2) + "%");
```

Output:

```text
11.83%
```

The highest example price is approximately 11.83% above the lowest example price.

This calculation uses the lower price as its baseline. Other definitions of percentage difference may use a different denominator, so document your method clearly.

## 5\. Build a Simple Price Comparison Interface

Next, let's display the dataset in an HTML table.

```html
<table>
  <thead>
    <tr>
      <th>Location</th>
      <th>Menu Item</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody id="priceRows"></tbody>
</table>
```

Now populate it using JavaScript.

```javascript
const tbody = document.querySelector("#priceRows");

for (const row of menuPrices) {
  const tr = document.createElement("tr");

  const location = document.createElement("td");
  location.textContent = row.location;

  const item = document.createElement("td");
  item.textContent = row.item;

  const price = document.createElement("td");
  price.textContent = new Intl.NumberFormat("en-US", {
    style: "currency",
    currency: row.currency
  }).format(row.price);

  tr.append(location, item, price);
  tbody.appendChild(tr);
}
```

This creates a readable comparison table without external dependencies.

Using `textContent` also avoids treating dataset strings as HTML, which is safer when displaying externally supplied data.

## 6\. Handle Missing and Outdated Prices

Real-world pricing data is rarely complete.

A restaurant might not publish every menu item online. A price may also have been collected months ago.

Instead of inventing missing values, represent them explicitly.

```javascript
const record = {
  item: "Caniac Combo",
  location: "Location D",
  price: null,
  currency: "USD",
  checkedAt: null
};

const displayPrice =
  record.price === null
    ? "Price unavailable"
    : `$${record.price.toFixed(2)}`;
```

For freshness, you can calculate the age of a record:

```javascript
function ageInDays(dateString, now = new Date()) {
  if (!dateString) return null;

  const checked = new Date(`${dateString}T00:00:00Z`);

  if (Number.isNaN(checked.getTime())) {
    return null;
  }

  const today = Date.UTC(
    now.getUTCFullYear(),
    now.getUTCMonth(),
    now.getUTCDate()
  );

  return Math.floor(
    (today - checked.getTime()) / 86400000
  );
}
```

An application can use this value to flag old records for review.

A stale price should not automatically be described as incorrect, but its collection date should remain visible.

## 7\. Working With Real Restaurant Menu References

For a real application, the next step is collecting reliable source information.

Suppose you're researching **Raising Cane's menu with prices 2026** or comparing **Cane's chicken prices** across locations.

An independent resource such as [CanesMenuPrices.com](https://canesmenuprices.com/) can provide menu-category context and a starting point for identifying items. However, it should not be treated as a verified real-time pricing API.

Actual prices should be confirmed through the restaurant's current ordering system.

For production data collection, follow the source's access terms, respect rate limits, and avoid assuming that publicly visible information is automatically licensed for unrestricted automated extraction.

A well-designed price comparison application should preserve source attribution and timestamps.

## 8\. Improvements for a Production Application

Our basic tool works with a small in-memory dataset, but a production system would need additional components.

**Database storage:** Store pricing records with restaurant IDs, location IDs, item IDs, and timestamps.

**Validation:** Reject invalid currencies, negative prices, and malformed dates.

**Price history:** Maintain historical records instead of overwriting earlier observations.

**Filtering:** Let users compare specific products or locations.

**Testing:** Add unit tests for calculations, missing values, and date handling.

**Accessibility:** Use semantic tables, readable labels, and keyboard-accessible controls.

If the application eventually supports multiple countries, currency conversion should be handled separately from restaurant pricing. Exchange rates introduce another data source and timestamp requirement.

## 9\. What This Project Teaches

A restaurant price comparison tool may seem simple, but it introduces several useful software engineering concepts.

You work with structured data, array transformations, input validation, DOM rendering, data freshness, and source reliability.

These concepts apply to many other projects, including product comparison websites, travel pricing dashboards, and inventory monitoring tools.

Most importantly, the project demonstrates why accurate data modeling matters as much as the interface displaying the results.

## Conclusion

Building a restaurant menu price comparison tool with JavaScript is a practical way to learn how real-world pricing data should be structured and presented.

Our example uses fictional Raising Cane's combo prices to demonstrate calculations without presenting test data as actual restaurant information.

The next step is to connect the interface to a properly maintained dataset, add filters, and create automated tests.

With a reliable data source and clear freshness indicators, the same architecture can support a much larger comparison application.
