← Back Creator Path 🦁 Safari Spotter Lesson 80/20
🎯 Missions
1 Release animals
2 Search with a clue
3 Spot the first match!
🦁 🐘 🦒
🔭 Savanna
Safari Spotter
Welcome to the Savanna! The grass is full of animals — but your clue card describes just ONE. Meet .find() — the ranger superpower that scans the herd and stops at the FIRST match. And .includes() tells you if a friend is on the safari at all!

🔭 What is .find()?

Imagine ranger binoculars sweeping across the herd, left to right. The moment an animal matches your clue — stop! That's .find(). It returns the first item that passes the test, and ignores everything after it.

// Find the first animal faster than 70 km/h
const speeds = [40, 65, 120, 80];

const fast = speeds.find(s => s > 70);
// Result: 120 (the FIRST one over 70)

What vs Where: In Neon Patrol you learned .findIndex() — it gives you the WHERE (a position number). .find() gives you the WHAT (the item itself)!

const animals = ["Zebra", "Cheetah", "Lion"];

animals.findIndex(a => a === "Cheetah") // → 1 (WHERE: index 1)
animals.find(a => a === "Cheetah") // → "Cheetah" (WHAT: the item)

What if nothing matches? .find() returns undefined — the ranger saw nothing today. Always check before using the result:

const tiger = animals.find(a => a === "Tiger");
if (tiger) { console.log("Found: " + tiger); } // doesn't run
else { console.log("No sighting today!"); }

And .includes()? It doesn't care WHERE or WHAT — it just answers yes or no (true/false). Perfect for simple values like strings and numbers:

const names = ["Zebra", "Cheetah", "Lion"];

names.includes("Lion") // → true
names.includes("Tiger") // → false 🙁
✏️ CODE
// 🔭 Safari Spotter — search the savanna! const spottings = [ { name: "Zebra", speed: 65 }, { name: "Cheetah", speed: 120 }, { name: "Lion", speed: 80 } ]; // .find() returns the FIRST match: const fastOne = spottings.find(a => a.speed > 70); console.log("First speedster: " + fastOne.name); // .includes() answers yes or no: const names = ["Zebra", "Cheetah", "Lion"]; console.log("Lion here? " + names.includes("Lion")); console.log("Tiger here? " + names.includes("Tiger"));
✨ RESULT
🦓On safari: 0
🔭Clue: predator 🐾
🎯Spotted:
Your Savanna
Release animals below!

🐘 Release Animals

🔍 Pick Your Clue Card

❓ Who Is Here? (.includes)

First Match

1 Challenge: Find the First Big Number

Scan the list and stop at the FIRST number greater than 10!

const numbers = [3, 8, 15, 22];
const big = numbers.find(n => n > 10);
// Result: 15 (22 never gets checked!)

2 Challenge: WHAT vs WHERE

Same test, two superpowers: .find() gives the item, .findIndex() gives the position!

const fruits = ["Apple", "Banana", "Cherry"];
fruits.find(f => f.length > 5); // → "Banana"
fruits.findIndex(f => f.length > 5); // → 1

3 Challenge: Membership Check

.includes() just answers true or false — no position, no item!

const safari = ["Elephant", "Lion", "Zebra"];
safari.includes("Lion"); // → true
safari.includes("Penguin"); // → false (wrong continent! 🐧)

4 Challenge: Nothing Found → undefined

When no animal passes the test, .find() returns undefined. Guard it with an if!

const animals = ["Zebra", "Lion"];
const whale = animals.find(a => a === "Whale");
if (whale) { console.log("Found: " + whale); }
else { console.log("No sighting!"); } // → "No sighting!"

5 Challenge: Filter + Find Combo

Master move! First .filter() to keep only predators, then .find() the first one faster than 100!

const animals = [
  { name: "Zebra", diet: "herbivore", speed: 65 },
  { name: "Lion", diet: "predator", speed: 80 },
  { name: "Cheetah", diet: "predator", speed: 120 }
];
const rocket = animals.filter(a => a.diet === "predator").find(a => a.speed > 100);
// Result: { name: "Cheetah", ... } 🏆

✨ What You Learned