Filter Search Results
Filter Search Results
filter keeps original items that pass a test. In search code, that means the result should contain the matching product records, not the string names and not a list of booleans.
The predicate can prepare the text it needs for comparison, but the returned array should still hold the records from the source list. That keeps later code free to read prices, ids, and other fields from each match.
Your task: Complete searchProducts so it returns products whose names include the trimmed query, ignoring case. Return an empty array when the query is blank.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Filter Search Results
filter keeps original items that pass a test. In search code, that means the result should contain the matching product records, not the string names and not a list of booleans.
The predicate can prepare the text it needs for comparison, but the returned array should still hold the records from the source list. That keeps later code free to read prices, ids, and other fields from each match.
Your task: Complete searchProducts so it returns products whose names include the trimmed query, ignoring case. Return an empty array when the query is blank.