JavaScript AcademyProfessional Engineering

Level 3 · Interactive Web Applications Project 26 of 60 Runs in the browser

Project 26: Flashcard Learning Application

A flashcard trainer that uses Leitner boxes: cards you know move to a higher box, cards you miss go back to box 1, and the weakest cards come first. Works fully from the keyboard.

Level 3 covers the DOM, events, forms, state and storage, so you write both files: the logic file holds pure state functions and app.js renders the state and handles events. Storage in the website's preview is memory-only; the downloaded project uses your browser's real localStorage.

1 · The problem

Reading notes again is a slow way to learn. Flashcards with spaced repetition are faster: you test yourself, and the cards you get wrong come back sooner. The app needs a clear front/back flip, keyboard shortcuts, a score for the session and cards that keep their box between visits.

User stories

  • As a learner, I want the cards I keep missing to come first.
  • As a learner, I want to study without touching the mouse.
  • As a learner, I want my progress kept for next time.

2 · Requirements

  • Each card has id, front, back and box (1 to 3).
  • Study cards in box order (lowest first), then by id.
  • Flip with a button that reports its state with aria-pressed; show the answer buttons only after flipping.
  • A right answer moves the card up one box (at most 3); a wrong one sends it back to box 1.
  • Show progress ('Card 2 of 4'), the cards per box and the session score.
  • Keyboard: F flips, Y marks right, N marks wrong (ignored while typing in the form).
  • Add new cards (both sides required) and save every change.

Acceptance criteria

  • The session starts on 'What does const prevent?' with 'Card 1 of 4'.
  • Flipping shows the back and the answer buttons.
  • After 3 right and 1 wrong the session shows 'Session complete' and '3 of 4 right (75%)'.
  • An empty side is refused with 'Enter both sides of the card.'

Architecture

LayerFileResponsibility
Pageindex.html + style.cssCard, flip and answer buttons, stats, add form.
Stateflashcards.jsStudy order, boxes, scores, adding cards. Your work.
View and eventsapp.jsshowCard, answers, keyboard, storage. Your work.

Flow: Flip → flipped = !flipped → showCard() · Answer → cards = answerCard(cards, id, correct) → save → next card → showCard() + renderStats()

Expected result

Flashcard Learning Application: finished app
finished app

Screenshots are captured automatically from the solution by the browser test suite.

Build it: guided stages

Pick a stage, load its starter files, follow the steps, then run the app and the tests. Every stage is preserved separately, so loading one never overwrites another.

  1. Stage 1: Show and flip a card · Pick the study order and show one card that flips.
  2. Stage 2: Answers, boxes and the keyboard · Record answers, move cards between boxes and add keyboard shortcuts.
  3. Stage 3: Add cards and save progress · Add your own cards and keep every box between visits.

Troubleshooting

Pressing N while typing a card marks an answer.
Return early from the keydown listener when event.target is inside an input.
The same card keeps coming back.
Increase index after each answer; the order is fixed at the start of a session.
A card shows undefined.
order holds ids. Find the card with cards.find((c) => c.id === order[index]).

Extension challenges

  1. Add a fourth box and only show box 3 cards every other session.
  2. Shuffle cards that share a box.
  3. Edit or delete a card.

Downloads

Browser projects open directly from index.html. Node.js unit tests: run node --test in the project folder.

AI development prompts

Context: I am building the academy's Flashcard Learning Application. Task: explain how the Leitner box system decides the study order. Constraints: explain the idea and point to the line that matters; do not write the whole solution. Expected behaviour: I can finish the stage myself. Testing: suggest two inputs that would show whether my code is right.
Context: My Flashcard Learning Application passes the visible tests. Task: check my keyboard handling for keys that fire while typing. Constraints: do not rewrite my code; list issues in order of importance. Expected behaviour: I understand each issue and can fix it. Testing: give one test case per issue.
Context: I finished the Flashcard Learning Application. Task: help me plan this extension: add a shuffle that keeps the box order. Constraints: keep the logic file free of page code; existing tests must still pass. Expected behaviour: a short plan with the functions to add or change. Testing: describe the new tests I should write first.

Source

Repository folder: projects/project-26-flashcard-learning-application/ · view on GitHub