Project 6: Testimonial Slider
JS Wizard
Builds on these lessons
Step 1 of 3
Project
find() & findIndex()
Use testimonials.find() to get the first 5-star testimonial object, and findIndex() to get its position in the array. Both stop searching the moment they find a match — find() hands back the element itself, findIndex() hands back where it lives.
🎯 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 testimonials = [
{ author: "Renee O.", rating: 4 },
{ author: "Tom A.", rating: 5 },
{ author: "Sam K.", rating: 3 }
];
const fiveStarReview = testimonials.find((t) => t.rating === 5);
const fiveStarIndex = testimonials.findIndex((t) => t.rating === 5);
console.log(fiveStarReview, fiveStarIndex);