A simple app that takes in a word and outputs the frequency of each character, rendered in a vertical list.
Use this CodeSandbox template to create or reset the app quickly:
- Controlled input field for user-typed word
- Click-to-calculate character frequency
- Dynamic rendering of characters and counts
- Clean functional component structure
- Minimal styling, focused on clarity
- React (with Hooks)
- TypeScript
- JavaScript Debugging Tools
- Browser DevTools
- CodeSandbox (cloud IDE)
To follow the data flow step-by-step:
-
Open DevTools Console
- See
console.log()messages as you type or click
- See
-
Use
debuggerkeyword- In
calculateFrequencies, adddebugger;to pause execution - Step through code line by line (F10 or ⬇️ button in DevTools)
- In
-
Install React DevTools
- View and inspect component state live
- See how
inputTextandfrequencieschange on interaction
-
Add breakpoints in Chrome
- In the Sources tab, click any line number to break there
- Hover variables to inspect values
- Use the Scope pane to see local variables
- 🔠 Add sorting (A–Z or frequency high-to-low)
- 🚫 Ignore whitespace or punctuation
- 🔄 Add a reset button
- ✅ Write unit tests using Jest or React Testing Library
- 🎨 Use Tailwind CSS or styled-components for styling
- 🧩 Refactor to use
index.tsxas an entry point
If you're not using this repo directly or a CodeSandbox fork, here’s how to set up the app from scratch using Vite:
npm create vite@latest character-frequency -- --template react-ts
cd character-frequency
npm install
npm run dev