Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
<h1 id = "topicHeading">Topic Areas</h1>
<p id = "topics">Please select the topics you are interested in being quizzed on below
<ul>
<li id = "functions">Functions</li>
<li id = "loops">Loops</li>
<li id = "objects">Objects</li>
<li id = "DOM">The DOM</li>
<li id = "localStorage">Local Storage</li>
</ul>
</p>
<h1 class= "title">Coding Quiz</h1>
<span id="quiz">
<p class= "populateQuestions"></p>
Expand Down
86 changes: 80 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//=============GLOBAL VARIABLES DECLARATION & ASSIGNMENT============
//creating an array that stores the questions for the topic 'functions'
let testBank = [];
let quizBank= [];
//counts the number of questions we ask, starting at zero for an array
let counter = 0;
Expand All @@ -21,6 +22,14 @@ let quizElement = document.getElementById('quiz');
let buttonHolder = document.getElementById('buttonHolder');
let questionButton= document.createElement('button');

//===TOPIC SELECTOR==

let elTopic1 = document.getElementById('functions')
let elTopic2 = document.getElementById('loops')
let elTopic3 = document.getElementById('objects')
let elTopic4 = document.getElementById('DOM')
let elTopic5 = document.getElementById('localStorage')

//===========OBJECT CONSTRUCTOR & INSTANCES============

//creating an object constructor with properties and method for the questions
Expand Down Expand Up @@ -69,7 +78,76 @@ q34 = new Question('DOM', 'Methods that find elements in the DOM are called what
q35 = new Question('DOM', 'A collection of nodes is known as a _______?', ['nodeList', 'nodeArray', 'nodeQuery', 'nodeScript'], null, null) ;

//pushing the questions of the function questions objects into an array that holds all the questions for the function topic
quizBank.push(q01, q02, q03, q04, q05, q11, q12, q21, q22, q23, q31, q32, q33, q34, q35);
testBank.push(q01, q02, q03, q04, q05, q11, q12, q21, q22, q23, q31, q32, q33, q34, q35);

// then attach an event handler
let topicChoice1 = function(e) {
for (z = 0; z < testBank.length; z++) {
if (document.getElementById('functions').id === testBank[z].topic) {
quizBank.push(testBank[z])
console.log(quizBank)
}
}

questionPopulate();
answerChoices();
answerEventFunc();
}

let topicChoice2 = function(e) {
for (z = 0; z < testBank.length; z++) {
if (document.getElementById('loops').id === testBank[z].topic) {
quizBank.push(testBank[z])
}
}

questionPopulate();
answerChoices();
answerEventFunc();
}

let topicChoice3 = function(e) {
for (z = 0; z < testBank.length; z++) {
if (document.getElementById('objects').id === testBank[z].topic) {
quizBank.push(testBank[z])
}
}

questionPopulate();
answerChoices();
answerEventFunc();
}

let topicChoice4 = function(e) {
for (z = 0; z < testBank.length; z++) {
if (document.getElementById('DOM').id === testBank[z].topic) {
quizBank.push(testBank[z])
}
}

questionPopulate();
answerChoices();
answerEventFunc();
}

let topicChoice5 = function(e) {
for (z = 0; z < testBank.length; z++) {
if (document.getElementById('localStorage').id === testBank[z].topic) {
quizBank.push(testBank[z])
}
}

questionPopulate();
answerChoices();
answerEventFunc();
}

// then attach an event listener
elTopic1.addEventListener('click', topicChoice1) ;
elTopic2.addEventListener('click', topicChoice2) ;
elTopic3.addEventListener('click', topicChoice3) ;
elTopic4.addEventListener('click', topicChoice4) ;
elTopic5.addEventListener('click', topicChoice5) ;

//=========Index for tracking what questions we are on===============

Expand Down Expand Up @@ -178,8 +256,4 @@ let removeEventFunc = function() {
}
}

questionButton.addEventListener('click', nextClicked)

questionPopulate();
answerChoices();
answerEventFunc();
questionButton.addEventListener('click', nextClicked)