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 >
7- < script defer src =" quotes.js " > </ script >
6+ < title > Quote generator app </ title >
7+ < link rel =" stylesheet " href =" style.css " / >
88 </ head >
99 < body >
1010 < h1 > hello there</ h1 >
1111 < p id ="quote "> </ p >
1212 < p id ="author "> </ p >
1313 < button type ="button " id ="new-quote "> New quote</ button >
14+ < script defer src ="quotes.js "> </ script >
1415 </ body >
1516</ html >
Original file line number Diff line number Diff line change @@ -491,3 +491,14 @@ const quotes = [
491491] ;
492492
493493// call pickFromArray with the quotes array to check you get a random quote
494+
495+ function displayQuote ( ) {
496+ const picked = pickFromArray ( quotes ) ;
497+ document . getElementById ( "quote" ) . innerText = picked . quote ;
498+ document . getElementById ( "author" ) . innerText = picked . author ;
499+ }
500+
501+ document . addEventListener ( "DOMContentLoaded" , ( ) => {
502+ displayQuote ( ) ;
503+ document . getElementById ( "new-quote" ) . addEventListener ( "click" , displayQuote ) ;
504+ } ) ;
Original file line number Diff line number Diff line change 1- /** Write your CSS in here **/
1+
2+ h1 , p , button {
3+ margin : 30px ;
4+ text-align : center;
5+ }
6+
7+ # new-quote {
8+ margin : 20px ;
9+ position : absolute;
10+ left : 50% ;
11+ -webkit-transform : translate ( -50% , -50% ) ;
12+ transform : translate ( -50% , -50% ) ;
13+ }
You can’t perform that action at this time.
0 commit comments