Build search and filter helpers for a product list.
You are building search helpers for a small product list. Some helpers should return multiple products, and one helper should return a single product.
Write these functions:
filterByCategory(products, category) should return products in the matching category.
filterByMaxPrice(products, maxPrice) should return products at or below the max price.
getInStockProducts(products) should return products where inStock is true.
findProductById(products, productId) should return one matching product or undefined.
searchProducts(products, searchText) should return products whose name includes the search text, ignoring casing.
Sample checks:
Expected output:
Search should be case-insensitive. The original products array should not be changed.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.