1- // your code goes in here
1+ const changeQuotesBtn = document . getElementById ( "new-quote_btn" ) ;
2+ const quote = document . getElementById ( "quote" ) . lastChild ;
3+ const author = document . getElementById ( "author" ) . lastChild ;
4+
5+ const quotes = [
6+ {
7+ quote : " Life is really simple, but we insist on making it complicated." ,
8+ author : " Confucius"
9+ } ,
10+ {
11+ quote : " I attribute my success to this: I never gave or took any excuse." ,
12+ author : " Florence Nightingale"
13+ } ,
14+ {
15+ quote : " Doing the best at this moment puts you in the best place for the next moment." ,
16+ author : " Oprah Winfrey"
17+ } ,
18+ {
19+ quote : " Trust yourself. You know more than you think you do." ,
20+ author : " Benjamin Spock"
21+ } ,
22+ {
23+ quote : " No one can make you feel inferior without your consent." ,
24+ author : " Eleanor Roosevelt"
25+ } ,
26+ {
27+ quote : " It is never too late to be what you might have been." ,
28+ author : " George Eliot"
29+ } ,
30+ ] ;
31+
32+ changeQuotesBtn . addEventListener ( "click" , changeQuote ) ;
33+
34+ function changeQuote ( ) {
35+ const index = Math . floor ( Math . random ( ) * 6 ) ;
36+ const newQuote = quotes [ index ] . quote ;
37+ const theAuthor = quotes [ index ] . author ;
38+ quote . textContent = newQuote ;
39+ author . textContent = theAuthor ;
40+ } ;
41+
0 commit comments