File tree Expand file tree Collapse file tree 3 files changed +72
-5
lines changed
Expand file tree Collapse file tree 3 files changed +72
-5
lines changed 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+ < title > Quote Generator App</ title >
7+ < link rel ="stylesheet " href ="style.css " />
78 < script defer src ="quotes.js "> </ script >
89 </ head >
910 < 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 >
11+ < h1 class ="greeting "> Hello There, Enjoy the Quote</ h1 >
12+ < div class ="quote-box ">
13+ < blockquote id ="quote "> </ blockquote >
14+ < p class ="author " id ="author "> </ p >
15+ < button type ="button " class ="btn " id ="new-quote "> New quote</ button >
16+ </ div >
1417 </ body >
1518</ html >
Original file line number Diff line number Diff line change 1+
2+
3+
14// DO NOT EDIT BELOW HERE
25
36// pickFromArray is a function which will return one item, at
1417// Examples of use
1518// ---------------
1619// pickFromArray(['a','b','c','d']) // maybe returns 'c'
20+
1721
1822// You don't need to change this function
1923function pickFromArray ( choices ) {
@@ -491,3 +495,17 @@ const quotes = [
491495] ;
492496
493497// call pickFromArray with the quotes array to check you get a random quote
498+ let randomQuote = pickFromArray ( quotes ) ;
499+ console . log ( randomQuote ) ; // maybe logs { quote: "...", author: "..." }
500+
501+ const quoteElement = document . getElementById ( "quote" ) ;
502+ const authorElement = document . getElementById ( "author" ) ;
503+ const newquoteButton = document . getElementById ( "new-quote" ) ;
504+
505+ function displayRandomQuote ( ) {
506+ const randomQuote = pickFromArray ( quotes ) ;
507+ quoteElement . innerText = `"${ randomQuote . quote } "` ;
508+ authorElement . innerText = `- ${ randomQuote . author } ` ;
509+ }
510+ displayRandomQuote ( ) ;
511+ newquoteButton . addEventListener ( "click" , displayRandomQuote ) ;
Original file line number Diff line number Diff line change 11/** Write your CSS in here **/
2+ body {
3+ margin : 0 ;
4+ height : 100vh ;
5+ display : flex;
6+ flex-direction : column;
7+ justify-content : center;
8+ align-items : center;
9+ background : # 4244c7 ;
10+ font-family : Arial, sans-serif;
11+ }
12+ .greeting {
13+ color : # fff ;
14+ margin-bottom : 50px ;
15+ font-size : 24px ;
16+ }
17+ .quote-box {
18+ background : # f0f0f0 ;
19+ padding : 20px 30px ;
20+ border-radius : 10px ;
21+ text-align : center;
22+ box-shadow : 0 4px 8px rgba (0 , 0 , 0 , 0.1 );
23+ }
24+
25+ blockquote {
26+ margin : 0 0 10px ;
27+ font-size : 28px ;
28+ color : # 080706c7 ;
29+ font-style : italic;
30+ font-weight : bold;
31+ }
32+ .author {
33+ margin : 0 0 15px ;
34+ color : # 1d0daf ;
35+ font-size : 20px ;
36+ font-weight : bold;
37+ }
38+
39+ .btn {
40+ background : # 4244c7 ;
41+ color : # fff ;
42+ border : none;
43+ padding : 8px 16px ;
44+ border-radius : 20px ;
45+ cursor : pointer;
46+ }
47+ .btn : hover { background : # eb2f48 ; }
You can’t perform that action at this time.
0 commit comments