File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -496,3 +496,19 @@ const quotes = [
496496const quoteElement = document . getElementById ( "quote" ) ;
497497const authorElement = document . getElementById ( "author" ) ;
498498const buttonElement = document . getElementById ( "new-quote" ) ;
499+
500+ function displayRandomQuote ( ) {
501+ // get a random quote from the quotes array
502+ const randomQuote = pickFromArray ( quotes ) ;
503+
504+ // update the quote and author elements
505+ quoteElement . textContent = randomQuote . quote ;
506+ authorElement . textContent = randomQuote . author ;
507+ }
508+
509+ displayRandomQuote ( ) ; // display a random quote when the page loads
510+
511+ // display a new random quote when button is clicked
512+ buttonElement . addEventListener ( "click" , ( ) => {
513+ displayRandomQuote ( ) ;
514+ } ) ;
You can’t perform that action at this time.
0 commit comments