1+ // call pickFromArray with the quotes array to check you get a random quote
2+ function displayRandomQuote ( ) {
3+ const quoteP = document . getElementById ( "quote" ) ;
4+ const authorP = document . getElementById ( "author" ) ;
5+
6+ const selectedQuote = pickFromArray ( quotes ) ;
7+
8+ quoteP . textContent = selectedQuote . quote ;
9+ authorP . textContent = selectedQuote . author ;
10+ }
11+
12+ // Setup event listener and display initial quote on load
13+ window . addEventListener ( "DOMContentLoaded" , ( ) => {
14+ displayRandomQuote ( ) ;
15+
16+ const newQuoteBtn = document . getElementById ( "new-quote" ) ;
17+ newQuoteBtn . addEventListener ( "click" , displayRandomQuote ) ;
18+ } ) ;
19+
120// DO NOT EDIT BELOW HERE
221
322// pickFromArray is a function which will return one item, at
@@ -489,22 +508,3 @@ const quotes = [
489508 author : "Zig Ziglar" ,
490509 } ,
491510] ;
492-
493- // call pickFromArray with the quotes array to check you get a random quote
494- function displayRandomQuote ( ) {
495- const quoteP = document . getElementById ( "quote" ) ;
496- const authorP = document . getElementById ( "author" ) ;
497-
498- const selectedQuote = pickFromArray ( quotes ) ;
499-
500- quoteP . textContent = selectedQuote . quote ;
501- authorP . textContent = selectedQuote . author ;
502- }
503-
504- // Setup event listener and display initial quote on load
505- window . addEventListener ( "DOMContentLoaded" , ( ) => {
506- displayRandomQuote ( ) ;
507-
508- const newQuoteBtn = document . getElementById ( "new-quote" ) ;
509- newQuoteBtn . addEventListener ( "click" , displayRandomQuote ) ;
510- } ) ;
0 commit comments