@@ -3,6 +3,10 @@ var beginButton = document.querySelector("#beginButton");
33var startPage = document . querySelector ( "#startPage" ) ;
44var scoresLink = document . querySelector ( "#scoresLink" ) ;
55
6+
7+ // Create these as global variables so that I can hide whichever is active when time runs out
8+ var question1 = document . createElement ( "h2" )
9+ var question2 = document . createElement ( "h2" )
610var question3 = document . createElement ( "h2" )
711
812var totalCorrect = 0 ;
@@ -22,7 +26,9 @@ function Quiz() {
2226 // stops the clock and hides it
2327 timeRemains = false ;
2428 countdown . setAttribute ( "style" , "display:none" ) ;
25- // hides the second question screen
29+ // hides the question screens
30+ question1 . setAttribute ( "style" , "display:none" ) ;
31+ question2 . setAttribute ( "style" , "display:none" ) ;
2632 question3 . setAttribute ( "style" , "display:none" ) ;
2733
2834 var finalScorePageHeader = document . createElement ( "h2" ) ;
@@ -34,7 +40,6 @@ function Quiz() {
3440
3541 function calculateFinalScore ( ) {
3642 finalScore = totalCorrect + ( Math . floor ( ( timeLeft / 5 ) ) ) ;
37- console . log ( timeLeft ) ;
3843
3944 localStorage . setItem ( "High Score" , JSON . stringify ( finalScore ) ) ;
4045
@@ -49,6 +54,7 @@ function Quiz() {
4954 finalScorePageHeader . appendChild ( finalScoreEntry ) ;
5055 finalScorePageHeader . appendChild ( finalScoreButton ) ;
5156
57+ // I would have liked to add multiple scores here- I think I would have needed to create multiple keys and used a series of "if" statements to determine if the previous keys already had values...
5258 function storeUserDetails ( ) {
5359 localStorage . setItem ( "User Initials" , JSON . stringify ( finalScoreEntry . value ) ) ;
5460 scoresLink . setAttribute ( "style" , "display:block" ) ;
@@ -83,7 +89,6 @@ function Quiz() {
8389 function questions ( ) {
8490 countdownTimer ( ) ;
8591
86- question1 = document . createElement ( "h2" )
8792 var answerList1 = document . createElement ( "button" )
8893 var answerList2 = document . createElement ( "button" )
8994 var answerList3 = document . createElement ( "button" )
@@ -127,7 +132,6 @@ function Quiz() {
127132 // hides the previous question and its answers
128133 question1 . setAttribute ( "style" , "display:none" ) ;
129134
130- var question2 = document . createElement ( "h2" )
131135 var secondAnswerList1 = document . createElement ( "button" )
132136 var secondAnswerList2 = document . createElement ( "button" )
133137 var secondAnswerList3 = document . createElement ( "button" )
@@ -166,7 +170,6 @@ function Quiz() {
166170
167171 function thirdQuestion ( ) {
168172 question2 . setAttribute ( "style" , "display:none" ) ;
169-
170173
171174 var thirdAnswerList1 = document . createElement ( "button" )
172175 var thirdAnswerList2 = document . createElement ( "button" )
0 commit comments