🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 17: Search Results Page

JS Wizard
Step 1 of 3
Project

A Higher-Order Function

Write filterResults(results, predicateFn) that returns results.filter(predicateFn). A function that takes another function as an argument (or returns one) is a higher-order function — filter, map, and reduce all fit that definition too.

🎯 Your Task

Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!

const results = [
  { title: "React Basics", type: "video" },
  { title: "CSS Grid Guide", type: "article" }
];

function filterResults(items, predicateFn) {
  return items.filter(predicateFn);
}

const videosOnly = filterResults(results, (r) => r.type === "video");
console.log(videosOnly);