File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -510,3 +510,25 @@ button.addEventListener("click", () => {
510510 const author = document . getElementById ( "author" ) ;
511511 author . innerText = randomQuote . author ;
512512} ) ;
513+
514+ function chooseQuote ( ) {
515+ const randomQuote = quotes [ Math . floor ( Math . random ( ) * quotes . length ) ] ;
516+
517+ const quote = document . getElementById ( "quote" ) ;
518+ quote . innerText = randomQuote . quote ;
519+
520+ const author = document . getElementById ( "author" ) ;
521+ author . innerText = randomQuote . author ;
522+ }
523+ const autoGenerate = document . getElementById ( "auto-play-toggle" ) ;
524+ let interval = null ;
525+ autoGenerate . addEventListener ( "change" , ( ) => {
526+
527+ if ( autoGenerate . checked ) {
528+ interval = setInterval ( chooseQuote , 2000 )
529+ } else {
530+ clearInterval ( interval )
531+ interval = null
532+ }
533+ } )
534+
You can’t perform that action at this time.
0 commit comments