Flashcards – a simple JavaScript app
The objective is to test your vocabulary. Building this simple game will improve your basic skills and knowledge of JavaScript.
Basic requirements
- The app has a hardcoded list of words with their translations.
- The app picks a random word from the list and shows the user the original word.
- The user enters the translation.
- The app checks whether the translation is correct. If it is, the word goes to the list of correct answers; if not, to the list of wrong ones. The app tells the user the result and, after a wrong answer, shows the correct one.
- Steps 2–4 repeat until there are no words left.
- At the end, the app shows a summary, for example the percentage of correct answers.
Interface, version 1
The app runs in the browser console. This keeps communication with the user simple: the user can type any command, and the app responds with console.log. To do this, create an index.html file that loads a main.js file. index.html explains the commands: open the console (F12), type flashcardsStart() to start the game, and so on. Treat index.html as a README.
Interface, version 2
Once all the requirements are met, build a graphical interface, so anyone can just click and type instead of using the console and learning the commands.
Testing
As this is a “command line” app, it should be fairly simple to test.
Future improvements
- Measure the time of each answer.
- Load the word list from a separate file. The file can be fetched, or just be a separate JavaScript file.
- Wrap the app in an object or a class.
- Put the code on your GitHub account, so you benefit from version control and can track your progress.