The Deep Vault holds 2000-year-old crystal formations โ but touching the wrong one triggers an ancient trap! ๐ In Crystal Cavern you learned to .sort() them. Now you need to ASK QUESTIONS: does this vault CONTAIN a blue crystal? (.some()) Are ALL crystals worth over 100? (.every()) The Crystal Scanner gives true or false in milliseconds โ and the wrong answer seals the cavern FOREVER!
๐ What we're MAKING today: My Crystal Scanner
In Crystal Cavern you used .sort() to re-order crystals.
Today you meet two new superpowers that don't change or remove anything โ they just
ask a yes/no question about the whole cave!
.some() โ scans the vault and answers: "Is there AT LEAST ONE crystal like this?"
It stops the moment it finds one. .every() โ scans and answers:
"Do ALL crystals match?" It stops the moment one breaks the rule. Both return
true or false โ a single answer for the whole collection!
๐ Last time (Crystal Cavern) you re-ordered crystals with .sort(). Today: no crystals are moved or changed โ you're just asking questions. 5 crystals in, 1 TRUE/FALSE answer out. That's the Scanner! ๐
scanner.jsJavaScript
๐ก Tap a query type below โ watch the code line change LIVE!.some() / .every() โ true / false
crystal vaultLIVE
๐ SCANNER READY
๐ CRYSTAL SCANNER
Tap a query, then press โถ Scan Vault โ the Scanner tells you TRUE or FALSE!
โข Crystals
5
Result
โ
๐ Rank
Apprentice
Challenge 1 / 5
Vault Alert! Check if any crystal is worth over 200โฆ
๐งฉ Choose ONE query to run PICK ONE
๐ง Which scanner reads the vault correctly? TAP ONE
๐ The Scanner checks every crystal and returns TRUE or FALSE. The code line updates the moment you pick a query!
๐ Your 5 Crystal Challenges
0 of 5 challenges scanned
๐
You Mastered Crystal Scanner!
Two questions, instant answers โ you navigated the Deep Vault like a true Crystal Guardian. The ancient seals stay open and the treasures are safe! ๐ฎ
๐ซ What You Learned
.some() โ Asks "Is there AT LEAST ONE item that passes my test?" Returns true if any match, stops early
.every() โ Asks "Do ALL items pass my test?" Returns true only if every single one passes, stops on first fail
Both return a single true/false โ a yes-or-no answer for the whole cave
Together with .filter(), .map(), .sort(), .find(), you now have the complete toolkit for answering any question about an array!
Real coders use .some()/.every() to check permissions, validate forms, and test game rules โ now you do too! ๐
๐ Your Creation
My Crystal Scanner
๐ Come Back Tomorrow!
Next up: Neon Beacon โ a new universe! You'll build a real-time display that tracks scores, highlights leaders, and updates live as data changes. Think: a sports scoreboard powered by JavaScript! โก