-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
49 lines (45 loc) · 1.62 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const generateQuoteBtn = document.getElementById("quoteBtn");
const quoteOutput = document.getElementById("quoteOutput");
const authorOutput = document.getElementById("authorOutput");
generateQuoteBtn.addEventListener("click", generateQuote);
const arrayOfQuotes = [
{
author: "Steve Jobs",
quote:
"The only way to do great work is to love what you do.",
},
{
author: " - Winston Churchill",
quote:
"Success is not final, failure is not fatal: It is the courage to continue that counts.",
},
{
author: "Eleanor",
quote:
"When you give joy to other people, you get more joy in return. You should give a good thought to happiness that you can give out.",
},
{
author: "Winston Churchill",
quote: "Success is stumbling from failure to failure with no loss of enthusiasm.",
},
{
author: "Walter",
quote:
"It is only when we take chances, when our lives improve. The initial and the most difficult risk that we need to take is to become honest. ",
},
{
author: "Diane McLaren",
quote:
"Nature has given us all the pieces required to achieve exceptional wellness and health, but has left it to us to put these pieces together.",
},
{
author: "Dale Carnegie",
quote:
"Develop success from failures. Discouragement and failure are two of the surest stepping stones to success.",
},
];
function generateQuote() {
let random = Number.parseInt(Math.random() * arrayOfQuotes.length + 1);
quoteOutput.innerHTML = `<span>${arrayOfQuotes[random].quote}</span>`;
authorOutput.innerHTML = `<small>-${arrayOfQuotes[random].author}-</small>`;
}