jsquotes/app.js

12 lines
340 B
JavaScript
Raw Normal View History

2023-01-22 10:03:28 -06:00
const disp = document.querySelector(".display");
fetch("FavouriteQuotes.json")
.then((response) => {
return response.json();
})
.then((data) => {
numQuotes = Object.entries(data).length;
num = Math.floor(Math.random() * numQuotes);
disp.innerText = data[num].quote + "\n\n" + data[num].author.replace(/"/g, '');
})