|
1 | | -// DO NOT EDIT BELOW HERE |
2 | | - |
3 | | -// pickFromArray is a function which will return one item, at |
4 | | -// random, from the given array. |
5 | | -// |
6 | | -// Parameters |
7 | | -// ---------- |
8 | | -// choices: an array of items to pick from. |
9 | | -// |
10 | | -// Returns |
11 | | -// ------- |
12 | | -// One item at random from the given array. |
13 | | -// |
14 | | -// Examples of use |
15 | | -// --------------- |
16 | | -// pickFromArray(['a','b','c','d']) // maybe returns 'c' |
17 | | - |
18 | | -// You don't need to change this function |
19 | 1 | function pickFromArray(choices) { |
20 | 2 | return choices[Math.floor(Math.random() * choices.length)]; |
21 | 3 | } |
22 | 4 |
|
23 | | -// A list of quotes you can use in your app. |
24 | | -// DO NOT modify this array, otherwise the tests may break! |
25 | 5 | const quotes = [ |
26 | 6 | { |
27 | 7 | quote: "Life isn't about getting and having, it's about giving and being.", |
@@ -490,24 +470,18 @@ const quotes = [ |
490 | 470 | }, |
491 | 471 | ]; |
492 | 472 |
|
493 | | -// getting access from the html |
494 | | -const showquote = document.querySelector("displayArea"); |
495 | | -const areaOfQuote = document.querySelector("h1"); |
| 473 | +const areaOfQuote = document.querySelector("#quote"); |
496 | 474 | const shufflebutton = document.querySelector("#new-quote"); |
497 | | -const AreaOfQuoteBy = document.querySelector("h3"); |
498 | | - |
499 | | -// call pickFromArray with the quotes array to check you get a random quote |
| 475 | +const AreaOfQuoteBy = document.querySelector("#author"); |
500 | 476 |
|
501 | 477 | function quoteGenerator() { |
502 | 478 | const entireQuote = pickFromArray(quotes); |
503 | 479 | const quot = entireQuote.quote; |
504 | 480 | const Author = entireQuote.author; |
505 | | - areaOfQuote.textContent = `" ${quot} "`; |
506 | | - AreaOfQuoteBy.textContent = `- ${Author}`; |
| 481 | + areaOfQuote.textContent = quot; |
| 482 | + AreaOfQuoteBy.textContent = Author; |
507 | 483 | } |
508 | | -//console.log(quoteGenerator); |
509 | | -//console.log(quot); |
510 | | -//console.log(Author); |
| 484 | + |
511 | 485 | quoteGenerator(); |
512 | | -//event handler |
| 486 | + |
513 | 487 | shufflebutton.addEventListener("click", quoteGenerator); |
0 commit comments