Skip to content

Commit 670779a

Browse files
add button functionality for new quotes
1 parent 31fcc7d commit 670779a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Sprint-3/quote-generator/quotes.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ function pickFromArray(choices) {
2020
return choices[Math.floor(Math.random() * choices.length)];
2121
}
2222

23-
24-
2523
// A list of quotes you can use in your app.
2624
// DO NOT modify this array, otherwise the tests may break!
2725
const quotes = [
@@ -494,9 +492,21 @@ const quotes = [
494492

495493
// call pickFromArray with the quotes array to check you get a random quote
496494

497-
//window.addEventListener("load",pickFromArray(quotes))
498495
const randomQuote = pickFromArray(quotes);
499-
const quote=document.getElementById("quote")
500-
const author=document.getElementById("author")
501-
quote.innerText=randomQuote.quote
502-
author.innerText=randomQuote.author
496+
497+
const quote = document.getElementById("quote");
498+
quote.innerText = randomQuote.quote;
499+
500+
const author = document.getElementById("author");
501+
author.innerText = randomQuote.author;
502+
503+
const button = document.getElementById("new-quote");
504+
button.addEventListener("click", () => {
505+
const randomQuote = pickFromArray(quotes);
506+
507+
const quote = document.getElementById("quote");
508+
quote.innerText = randomQuote.quote;
509+
510+
const author = document.getElementById("author");
511+
author.innerText = randomQuote.author;
512+
});

0 commit comments

Comments
 (0)