diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..37799738b 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,15 +1,18 @@ - + - Title here + Quote generator app + -

hello there

-

-

- +
+

+

+

+ +
diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..17a17b351 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -17,7 +17,21 @@ // You don't need to change this function function pickFromArray(choices) { - return choices[Math.floor(Math.random() * choices.length)]; + return choices[Math.floor(Math.random() * choices.length)]; // Math.random() generates a random number between 0 (inclusive) and 1 (exclusive). Multiplying it by choices.length gives a random number between 0 and the length of the array. Math.floor() rounds it down to the nearest whole number, which is used as an index to pick an item from the array. +} +function setup() { + const button = document.getElementById("new-quote"); // Get the button element using its DOM ID + const quoteElement = document.getElementById("quote"); + const authorElement = document.getElementById("author"); + + function renderRandomQuote() { + const selectedQuote = pickFromArray(quotes); // Call the pickFromArray function with the quotes array to get a random quote + quoteElement.innerText = selectedQuote.quote; // Display quote + authorElement.innerText = selectedQuote.author; // Display author + } + + renderRandomQuote(); + button.addEventListener("click", renderRandomQuote); // Add a click event listener to the button } // A list of quotes you can use in your app. @@ -491,3 +505,4 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote +setup(); diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css deleted file mode 100644 index 63cedf2d2..000000000 --- a/Sprint-3/quote-generator/style.css +++ /dev/null @@ -1 +0,0 @@ -/** Write your CSS in here **/