Add Question/Answer Object to our Data with Node.js writeFile

Share this video with your friends

Send Tweet

All of our questions have been hard coded so far. We want the user to be able to add a question when they pass the --add flag.

We will need to use inquirer to ask for a question and it's answer. Once we have a question and answer in hand we will read our data.json file and then write to it with our new question. While we do this, we will assign a unique id to the question based on the length of the array being stored in our file.