From cda38e04bcf8a5039f6097bb76d2d50b8a097832 Mon Sep 17 00:00:00 2001 From: Tisdale511 Date: Thu, 21 Jan 2021 14:25:49 -0500 Subject: [PATCH 1/2] task completed, fixed issue with author --- js/app.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/js/app.js b/js/app.js index d7e74c8..337aa46 100644 --- a/js/app.js +++ b/js/app.js @@ -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 based 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; }); })(); From 5c47fb7f2584d61ccf5d2f074dde36c4f2b0f53d Mon Sep 17 00:00:00 2001 From: Tisdale511 Date: Thu, 21 Jan 2021 14:38:59 -0500 Subject: [PATCH 2/2] test --- js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index 337aa46..69b1b69 100644 --- a/js/app.js +++ b/js/app.js @@ -36,7 +36,7 @@ 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 based on which element is selected from the quotes array + let the author and quote change text base on which element is selected from the quotes array */ const button = document.getElementById("generate-btn");