Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Arrays!
You have completed JavaScript Arrays!
Preview
It's time to put what you've learned about arrays into practice! In this exercise, you will build a quiz app.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
It's time to put what you've
learned about arrays into practice.
0:00
In this exercise,
you will build a quiz app.
0:03
And the first part of this challenge,
the app will ask a series of questions and
0:06
evaluate each answer.
0:10
The program keeps track of the number
of questions answered correctly.
0:12
After the user answers all questions,
0:16
the app displays the number of
questions correctly answered.
0:18
To get started, launch the new
workspace with this video, or
0:21
download the project files and
use your preferred text editor.
0:24
When you open the file quiz.js, you'll
notice that it contains several JavaScript
0:28
comments with instructions
on what you'll need to do.
0:33
You'll use some of the concepts from
this course to complete this challenge.
0:35
First, you'll need to create
a multidimensional array
0:39
to hold the questions and answers.
0:43
Each element of the array
represents one question and
0:46
is itself an array composed of two elements,
the question and the answer.
0:49
Create a two-dimensional array with
at least three questions in it.
0:54
You'll also need to store and
0:58
keep track of the number of
questions answered correctly.
1:00
Then you'll need to use a loop to cycle
through each question presented to
1:04
the user and compare the response from
the user to the answer in the array.
1:08
You can, for example, use the prompt
method to ask the questions.
1:13
And you can use a conditional statement
to check if the user's answer
1:17
matches the correct answer.
1:20
When the loop ends,
1:23
your program should have kept track of how
many questions were correctly answered.
1:24
So you'll need to display the number
of correct answers to the user.
1:28
You can use
the document.querySelector method
1:32
to select the main element of index.html
and display the final message.
1:35
In the next video, I'll show you one
solution to this challenge, good luck.
1:40
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up