Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@
}
];

const btn = document.getElementById("generate-btn");
/*
make button variable
attach event listener to button with 'click', function() {}
inside of function, create randomizer for each element in the quotes array, assign it to variable
let the author and quote change text base on which element is selected from the quotes array
*/
const button = document.getElementById("generate-btn");

btn.addEventListener("click", function() {
let random = Math.floor(Math.random() * quotes.length);
console.log(random);
button.addEventListener('click', function() {
let random = Math.floor(Math.random()*quotes.length);

document.querySelector('.author').textContent = quotes[random].author;
document.getElementById('quote').textContent = quotes[random].quote;

document.getElementById("quote").textContent = quotes[random].quote;
document.querySelector(".author").textContent = quotes[random].author;
});
})();