@@ -20,8 +20,6 @@ function pickFromArray(choices) {
2020 return choices [ Math . floor ( Math . random ( ) * choices . length ) ] ;
2121}
2222
23-
24-
2523// A list of quotes you can use in your app.
2624// DO NOT modify this array, otherwise the tests may break!
2725const quotes = [
@@ -494,9 +492,21 @@ const quotes = [
494492
495493// call pickFromArray with the quotes array to check you get a random quote
496494
497- //window.addEventListener("load",pickFromArray(quotes))
498495const randomQuote = pickFromArray ( quotes ) ;
499- const quote = document . getElementById ( "quote" )
500- const author = document . getElementById ( "author" )
501- quote . innerText = randomQuote . quote
502- author . innerText = randomQuote . author
496+
497+ const quote = document . getElementById ( "quote" ) ;
498+ quote . innerText = randomQuote . quote ;
499+
500+ const author = document . getElementById ( "author" ) ;
501+ author . innerText = randomQuote . author ;
502+
503+ const button = document . getElementById ( "new-quote" ) ;
504+ button . addEventListener ( "click" , ( ) => {
505+ const randomQuote = pickFromArray ( quotes ) ;
506+
507+ const quote = document . getElementById ( "quote" ) ;
508+ quote . innerText = randomQuote . quote ;
509+
510+ const author = document . getElementById ( "author" ) ;
511+ author . innerText = randomQuote . author ;
512+ } ) ;
0 commit comments