Task 1: Minimum Viable Quiz
For Task 1, you are going to:
- Ask the candidate for their name
- Create a quiz that asks a single question
- Check if the candidate answered the question correctly
- Inform the candidate if they answered the question correctly or not
- Create a greeting using the candidate’s name
The starter code contains functions. These pieces of code will be covered later in this course. However, instructions have been provided to help you work with them. The final page of these instructions will have a little more information about functions if you are curious.
We have added TODO
statements in the starter code to guide you with these functions.
For the sake of this assignment, look for the TODO
statements. Some are outside of a function, and some are within a function. The location indicates where you should add your code.
1.1 candidateName
- Ask for the candidate’s name.
- Look for
TODO 1.1a
in the starter code. - On the line below the TODO statement, define a variable called
candidateName
. - Declare this variable as an empty string.
- Look for
- Look for
TODO 1.1b
inside theaskForName
function.- On the line below the TODO statement (and inside the function), write code that asks the user to enter their name into the program and store the value as
candidateName
.
- On the line below the TODO statement (and inside the function), write code that asks the user to enter their name into the program and store the value as
- Look for
TODO 1.1c
Underneath it, there is an emptyconsole.log
statement. Write a message to the console greeting the user with the name they just provided.
1.2 Single Question Quiz
Ask the user to answer a single quiz question. Look for
TODO 1.2a
. Below the TODO statement, define variables calledquestion
,correctAnswer
, andcandidateAnswer
.question
should be initialized to the following string:"Who was the first American woman in space? "
.
NoteDon’t forget the trailing space at the end of this string! It is required.
correctAnswer
should be initialized to"Sally Ride"
.candidateAnswer
will initially be set to the empty string.
Find
TODO 1.2b
. Using your question variable, display the question and prompt the candidate for their answer. Store their response in one of the variables you defined just above.
Under TODO 1.2c
, check the candidate’s answer to see if it is correct. Provide basic feedback to the candidate, letting them know if their answer is correct or not.
Testing Task 1
In the terminal run npm test
. This will run the autograding tests. The results will display in the terminal.
To pass Task 1, you need to pass tests 1-6.
To see which tests you passed, scroll up in your terminal. You will see details of each test. At the top of the test results, you will find a list that displays all of the tests and each status. This can be used a quick reference. The detailed outputs can help you explore the cause of a failure which can help you debug and improve your code.
The rest of the tests are for Tasks 2 and 3.
Make sure your small app works properly before moving on to task 2.
Run the following command to make sure the app is running without errors, if you do encounter any errors:
- Revisit the above instructions step by step to ensure you completed all steps in Task 1.
- If you are still encountering problems, take a look back at this page and reach out to your instructional assistant.
node index.js
This is also a great time to save, commit, and push up your work.
Ready for Task 2