-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (18 loc) · 703 Bytes
/
Copy pathindex.js
File metadata and controls
30 lines (18 loc) · 703 Bytes
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
function showQuote() {
fetch("https://type.fit/api/quotes")
.then(function (response) {
return response.json();
})
.then(function (data) {
var rand = Math.floor(Math.random() * (data.length - 1 + 1) + 1);
var quote = (data[rand].text);
var author = (data[rand].author);
if (data[rand].author == null) {
author = "Anonymous"
} else {
author = data[rand].author;
}
document.getElementById('quote').innerHTML = '"' + quote + '"';
document.getElementById('author').innerHTML = author;
});
}