MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Product Filter App0%
Study Materials
JavaScript for IntermediateProgress 0%
1.1Block Scope with let & const1.2Template Literals1.3Destructuring Arrays and Objects1.4Default Parameters1.5Enhanced Object Literals
14.1Quiz App14.2To-Do List with Local Storage14.3Product Filter App
HomeTutorialsJavaScript for IntermediateProduct Filter App
Weather App using Fetch API & Async/Await

Product Filter App

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study Materials

E-commerce catalogs and data dashboards rely on multi-faceted filtering—allowing users to filter products simultaneously by category, maximum price range, and real-time search query. In this project, we implement a multi-criteria Product Filter Application.


1. Project Specifications

  1. 1
    Multi-Faceted Filtering: Filter simultaneously by:
  • Search term (text input matching product title or description).
  • Category dropdown (All, Electronics, Footwear, Accessories).
  • Price range slider with dynamic maximum value readout.
  1. 1
    Declarative Pipeline: Filter array using Array.prototype.filter().
  2. 2
    Empty State: Display an empty state card when no products match.
  3. 3
    Performance: Efficient DOM rendering with DocumentFragment.

2. HTML Markup (index.html)

1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6 <title>GearShop: Dynamic Product Catalog</title>
7 <link rel="stylesheet" href="style.css" />
8</head>
9<body>
10 <div class="layout">
11 <aside class="sidebar">
12 <h2>Filters</h2>
13 
14 <div class="filter-group">
15 <label for="search-input">Search Products</label>
16 <input type="search" id="search-input" placeholder="e.g. Wireless, Pro..." />
17 </div>
18 
19 <div class="filter-group">
20 <label for="category-select">Category</label>
21 <select id="category-select">
22 <option value="all">All Categories</option>
23 <option value="electronics">Electronics</option>
24 <option value="footwear">Footwear</option>
25 <option value="accessories">Accessories</option>
26 </select>
27 </div>
28 
29 <div class="filter-group">
30 <div class="range-header">
31 <label for="price-range">Max Price</label>
32 <span id="price-display">$500</span>
33 </div>
34 <input type="range" id="price-range" min="20" max="500" step="10" value="500" />
35 </div>
36 </aside>
37 
38 <main class="main-content">
39 <header class="catalog-header">
40 <h1>Product Catalog</h1>
41 <span id="result-count">Showing 0 products</span>
42 </header>
43 
44 <div id="product-grid" class="product-grid"></div>
45 <div id="empty-state" class="empty-state hidden">
46 <p>No products match your active filter criteria.</p>
47 </div>
48 </main>
49 </div>
50 
51 <script src="app.js"></script>
52</body>
53</html>

3. Styling the Catalog (style.css)

1:root {
2 --primary: #3b82f6;
3 --bg: #0b0f19;
4 --surface: #1e293b;
5 --text: #f8fafc;
6 --text-muted: #94a3b8;
7 --border: #334155;
8}
9 
10body {
11 margin: 0;
12 font-family: system-ui, -apple-system, sans-serif;
13 background: var(--bg);
14 color: var(--text);
15}
16 
17.layout {
18 display: grid;
19 grid-template-columns: 280px 1fr;
20 min-height: 100vh;
21}
22 
23.sidebar {
24 background: var(--surface);
25 padding: 2rem;
26 border-right: 1px solid var(--border);
27 display: flex;
28 flex-direction: column;
29 gap: 1.5rem;
30}
31 
32.filter-group { display: flex; flex-direction: column; gap: 0.5rem; }
33.filter-group label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
34 
35input[type="search"], select {
36 padding: 0.75rem;
37 border-radius: 0.5rem;
38 border: 1px solid var(--border);
39 background: #0f172a;
40 color: var(--text);
41}
42 
43.range-header { display: flex; justify-content: space-between; font-size: 0.85rem; }
44 
45.main-content { padding: 2rem; }
46.catalog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
47 
48.product-grid {
49 display: grid;
50 grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
51 gap: 1.5rem;
52}
53 
54.product-card {
55 background: var(--surface);
56 border: 1px solid var(--border);
57 border-radius: 0.75rem;
58 padding: 1.5rem;
59 display: flex;
60 flex-direction: column;
61 justify-content: space-between;
62}
63 
64.badge {
65 background: rgba(59, 130, 246, 0.15);
66 color: var(--primary);
67 font-size: 0.75rem;
68 padding: 0.25rem 0.5rem;
69 border-radius: 999px;
70 align-self: flex-start;
71}
72 
73.price { font-size: 1.25rem; font-weight: bold; color: #10b981; margin-top: 1rem; }
74.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
75.hidden { display: none !important; }

4. Application Logic (app.js)

1// Product Database
2const products = [
3 { id: 1, name: 'Wireless Noise-Canceling Headphones', category: 'electronics', price: 299 },
4 { id: 2, name: 'Mechanical Gaming Keyboard', category: 'electronics', price: 149 },
5 { id: 3, name: 'Ultra-Lightweight Trail Running Shoes', category: 'footwear', price: 120 },
6 { id: 4, name: 'Waterproof Leather Hiking Boots', category: 'footwear', price: 220 },
7 { id: 5, name: 'Minimalist Minimal Cardholder Wallet', category: 'accessories', price: 35 },
8 { id: 6, name: 'Aviator UV400 Sunglasses', category: 'accessories', price: 85 },
9 { id: 7, name: 'Smart Fitness Tracker Watch', category: 'electronics', price: 180 },
10 { id: 8, name: 'Breathable Running Socks (3-Pack)', category: 'accessories', price: 25 }
11];
12 
13// Elements
14const searchInput = document.querySelector('#search-input');
15const categorySelect = document.querySelector('#category-select');
16const priceRange = document.querySelector('#price-range');
17const priceDisplay = document.querySelector('#price-display');
18const productGrid = document.querySelector('#product-grid');
19const emptyState = document.querySelector('#empty-state');
20const resultCount = document.querySelector('#result-count');
21 
22function applyFilters() {
23 const searchTerm = searchInput.value.toLowerCase().trim();
24 const selectedCategory = categorySelect.value;
25 const maxPrice = parseFloat(priceRange.value);
26 
27 // Multi-faceted Declarative Filter Pipeline
28 const filtered = products.filter(product => {
29 const matchesSearch = product.name.toLowerCase().includes(searchTerm);
30 const matchesCategory = selectedCategory === 'all' || product.category === selectedCategory;
31 const matchesPrice = product.price <= maxPrice;
32 
33 return matchesSearch && matchesCategory && matchesPrice;
34 });
35 
36 renderProducts(filtered);
37}
38 
39function renderProducts(items) {
40 productGrid.innerHTML = '';
41 resultCount.textContent = `Showing ${items.length} ${items.length === 1 ? 'product' : 'products'}`;
42 
43 if (items.length === 0) {
44 emptyState.classList.remove('hidden');
45 return;
46 }
47 
48 emptyState.classList.add('hidden');
49 const fragment = document.createDocumentFragment();
50 
51 items.forEach(product => {
52 const card = document.createElement('div');
53 card.className = 'product-card';
54 
55 const categoryBadge = document.createElement('span');
56 categoryBadge.className = 'badge';
57 categoryBadge.textContent = product.category.toUpperCase();
58 
59 const title = document.createElement('h3');
60 title.textContent = product.name;
61 
62 const price = document.createElement('div');
63 price.className = 'price';
64 price.textContent = `$${product.price.toFixed(2)}`;
65 
66 card.append(categoryBadge, title, price);
67 fragment.appendChild(card);
68 });
69 
70 productGrid.appendChild(fragment);
71}
72 
73// Event Listeners
74searchInput.addEventListener('input', applyFilters);
75categorySelect.addEventListener('change', applyFilters);
76priceRange.addEventListener('input', (e) => {
77 priceDisplay.textContent = `$${e.target.value}`;
78 applyFilters();
79});
80 
81// Initial Render
82applyFilters();

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
How does the multi-criteria filter pipeline combine search, category, and price checks?
Question 2
Why is DocumentFragment used when rendering filtered product cards?
Question 3
What event type triggers filter updates as the user moves the price range slider?
Question 4
How is case-insensitive matching ensured when searching product names?
Question 5
What UI state is displayed when zero products match the filter criteria?
Next Lesson

Weather App using Fetch API & Async/Await

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
To-Do List with Local StorageWeather App using Fetch API & Async/Await

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Intermediate with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext