Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dedekind561 committed Oct 17, 2023
1 parent 83ecafe commit 738039a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions week-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<h1>hello there!!!</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
Expand Down
17 changes: 8 additions & 9 deletions week-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// ---------------
// pickFromArray(['a','b','c','d']) // maybe returns 'c'


// You don't need to change this function
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
Expand Down Expand Up @@ -494,17 +493,17 @@ const quotes = [
// call pickFromArray with the quotes array to check you get a random quote

const randomQuote = pickFromArray(quotes);
const $quote = document.querySelector('#quote');
const $quote = document.querySelector("#quote");
const $author = document.querySelector("#author");
const $button = document.querySelector('button');
updateQuote(randomQuote)

function updateQuote({quote, author}) {
const $button = document.querySelector("button");
updateQuote(randomQuote);
console.log("****");
function updateQuote({ quote, author }) {
$quote.innerText = quote;
$author.innerText = author;
}

$button.addEventListener('click',function handleClick() {
$button.addEventListener("click", function handleClick() {
const { quote, author } = pickFromArray(quotes);
updateQuote({ quote, author })
});
updateQuote({ quote, author });
});

0 comments on commit 738039a

Please sign in to comment.