Now that we can read from files, we don't need to hardcode any data in our script. Instead, we can import a json file and use readFile
to access questions and answers from the contents within.
We can then prompt the user with the question from the file and check the users answer against the answer that is stored.
Note: Checking the answer is just JavaScript! I set up this logic for you so we can focus on the scripting/file system side of things.