Projects
Web Dev Basics
Description
This project is a React flashcard study app for beginner web development concepts. Users can flip cards, type a guess before seeing the answer, get visual correct/incorrect feedback, move through the deck in order, or switch into a random practice mode.
Features
- Flip cards to reveal answers after guessing
- Guess input with submit feedback and custom correct/try-again images
- Next and previous navigation that stops at the start and end of the deck
- Normal and random mode toggle for ordered studying or shuffled practice
- Flexible answer checking that ignores extra spaces, capitalization, and punctuation
- Strawberry-inspired visual theme with 20 beginner web development cards
Normalizes a typed guess so small differences in capitalization or punctuation still count as correct:
const normalizeAnswer = (answer) => {
return answer.toLowerCase().replace(/[^\w\s]/g, '').trim()
}
const checkAnswer = (e) => {
e.preventDefault()
if (normalizeAnswer(userGuess) === normalizeAnswer(currentCard.answer)) {
setFeedback('CORRECT!')
} else {
setFeedback('TRY AGAIN!')
}
}
Moves through cards in order during normal mode, or picks a new random card while keeping a short history:
const goToNextCard = () => {
if (mode === "random") {
let randomIndex = Math.floor(Math.random() * flashcards.length)
while (randomIndex === currentCardIndex) {
randomIndex = Math.floor(Math.random() * flashcards.length)
}
const newHistory = cardHistory.slice(0, historyPosition + 1)
newHistory.push(randomIndex)
setCardHistory(newHistory)
setHistoryPosition(newHistory.length - 1)
setCurrentCardIndex(randomIndex)
resetCardView()
} else if (currentCardIndex < flashcards.length - 1) {
setCurrentCardIndex(currentCardIndex + 1)
resetCardView()
}
}
Outcome
A playful study tool with clear feedback and two ways to practice. Building it helped me get more comfortable managing several pieces of React state at once, from the current card to guess feedback and navigation modes.
Visit this project's GitHub repository here: GitHub Repository