Offload Complex Logic and Confirm a Correct Answer with the User

Share this video with your friends

Send Tweet

One issue with our script is that the answer that is checked needs to be exactly the same string as the answer in the file system. This can be brittle because your user might not capitalize or forget a space. There are ways we could sanitize user data but this can introduce quite a lot of complex logic into our script.

A great work around is to use Inquirer to check with the user if they got the answer right or wrong, this way you know you are logging correct values and you don't need to worry about sanitizing data as the user is determining for themself if they were right.