UNIT 25 • STAGE 4 OF 7
Filter buttons and JavaScript that shows only matching cards
The category filter uses the exact same pattern you learned in Unit 23: read btn.dataset.filter, compare it to card.dataset.category, show or hide. The pattern is worth repeating here because recognizing it in new contexts is a key programming skill.
Add a second <script> block after the flip script:
Note the ternary operator: (filter === 'all' || ...) ? '' : 'none'. This is shorthand for an if/else: if the condition is true, use the first value; otherwise, use the second. It keeps the logic concise.
Both JS features work: click a tab to filter, click a card to flip.
Next: Stage 5 adds the about section explaining Lakota language revitalization.