-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path100-projects-019-random-quote2.js
More file actions
43 lines (38 loc) · 3.03 KB
/
100-projects-019-random-quote2.js
File metadata and controls
43 lines (38 loc) · 3.03 KB
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
'use strict'
//This array will hold the quotes that will be randomly displayed
let quotes = [
"Somewhere, something increadible is waiting to be known.",
"We are a way for the cosmos to know itself.",
"Science is a way of thinking much more than it is a body of knowledge.",
"For small creatures such as we the vastness is bearable only through love.",
"We're made of star stuff. We are a way for the universe to know itself.",
"Extraordinary claims require extraordinary evidence.",
"In science it often happens that scientists say, 'You know that's a really good arguement; my position is mistaken,' and then they would actually change their minds and you never hear that old view from them again.",
"The cosmos is within us. We are made of star-stuff. We are a way for the universe to know itself.",
"The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together.",
"It is far better to grasp the universe as it really is than to persist in delusion, however satisfying and reassuring.",
"We can judge our progress by the courage of our questions and the depth of our answers, our willingness to embrace what is true rather what feels good.",
"The universe is not required to be in perfect harmony with human ambition.",
"One of the saddest lessons of history is this: If we've been bamboozled long enough, we tend to reject any evidence of the bamboozle. We're no longer interested in finding out the truth.",
"Look again at that dot. That's here. That's home. That's us. On it everyone you love, everyone you know, everyone you ever heard of, every human being who ever was, lived out their lives.",
"Imagination will often carry us to worlds that never were, but without it we go nowhere.",
"The nitrogen in our DNA, the calcium in out teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars. We are made of star-stuff.",
"Who are we? We find that we live on an insignificant planet of a humdrum star lost in a galaxy tucked away in some forgotten corner of a universe in which their are far more galaxies than people.",
"Books break the shackles of time - proof that humans can work magic.",
"It pays to keep an open mind, but not so open your brains fall out.",
"Our species needs, and deserves, a citizendry with minds wide awake and a basic understanding of how the world works."
];
//This function selects a random quote from the array
function getRandomQuote() {
let randomIndex = Math.floor(Math.random() * quotes.length);
return quotes[randomIndex];
}
//This function updates the text of the #quote paragraph with a new random quote
function displayNewQuote() {
let quote = getRandomQuote();
document.getElementById('quote').textContent = quote;
}
//Even listener calls displayNewQuote each time button is pressed
document.getElementById('new-quote-button').addEventListener('click', displayNewQuote);
//This line displays a quote when the page is first loaded
window.onload = displayNewQuote;