File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 < head >
44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6- < title > Title here</ title >
6+
7+ < title > Quote generator app</ title >
8+
9+ < link rel ="stylesheet " href ="style.css " />
710 < script defer src ="quotes.js "> </ script >
811 </ head >
12+
913 < body >
10- < h1 > hello there</ h1 >
11- < p id ="quote "> </ p >
12- < p id ="author "> </ p >
13- < button type ="button " id ="new-quote "> New quote</ button >
14+ < main >
15+ < h1 > Quote Generator</ h1 >
16+
17+ < blockquote id ="quote "> </ blockquote >
18+ < p id ="author "> </ p >
19+
20+ < button type ="button " id ="new-quote "> New quote</ button >
21+ </ main >
1422 </ body >
15- </ html >
23+ </ html >
Original file line number Diff line number Diff line change @@ -491,3 +491,20 @@ const quotes = [
491491] ;
492492
493493// call pickFromArray with the quotes array to check you get a random quote
494+
495+ function displayRandomQuote ( ) {
496+ const selectedQuote = pickFromArray ( quotes ) ;
497+
498+ document . getElementById ( "quote" ) . textContent = selectedQuote . quote ;
499+ document . getElementById ( "author" ) . textContent = selectedQuote . author ;
500+ }
501+
502+ function setup ( ) {
503+ const newQuoteButton = document . getElementById ( "new-quote" ) ;
504+
505+ newQuoteButton . addEventListener ( "click" , displayRandomQuote ) ;
506+
507+ displayRandomQuote ( ) ;
508+ }
509+
510+ window . onload = setup ;
You can’t perform that action at this time.
0 commit comments