Skip to content

Commit 70b8e5e

Browse files
author
russom
committed
Quote generator: only include Sprint-3/quote-generator changes
1 parent 4222cda commit 70b8e5e

3 files changed

Lines changed: 54 additions & 2 deletions

File tree

‎Sprint-3/quote-generator/index.html‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Title here</title>
6+
<title>Quote generator app"</title>
77
<script defer src="quotes.js"></script>
8+
<link rel="stylesheet" href="style.css">
89
</head>
910
<body>
10-
<h1>hello there</h1>
11+
<h1>Welcome</h1>
1112
<p id="quote"></p>
1213
<p id="author"></p>
1314
<button type="button" id="new-quote">New quote</button>

‎Sprint-3/quote-generator/quotes.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// pickFromArray(['a','b','c','d']) // maybe returns 'c'
1717

1818
// You don't need to change this function
19+
1920
function pickFromArray(choices) {
2021
return choices[Math.floor(Math.random() * choices.length)];
2122
}
@@ -490,4 +491,27 @@ const quotes = [
490491
},
491492
];
492493

494+
//console.log(pickFromArray(quotes));
493495
// call pickFromArray with the quotes array to check you get a random quote
496+
497+
//When the page loads it should show a random quote from the `quotes` array on the screen. It should also show who said the quote.
498+
499+
//When you click a button on the screen it should change the quote on the screen.
500+
501+
const button = document.querySelector("#new-quote");
502+
const quoteText = document.querySelector("#quote");
503+
const quoteAuthor = document.querySelector("#author");
504+
505+
function showRandomQuote() {
506+
const randomQuote = pickFromArray(quotes);
507+
quoteText.textContent = randomQuote.quote;
508+
quoteAuthor.textContent = randomQuote.author;
509+
}
510+
511+
showRandomQuote();
512+
513+
button.addEventListener("click", showRandomQuote);
514+
515+
//function pickFromArray(choices) {
516+
// return choices[Math.floor(Math.random() * choices.length)];
517+
//}

‎Sprint-3/quote-generator/style.css‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
11
/** Write your CSS in here **/
2+
3+
body {
4+
color: rgb(48, 46, 46);
5+
background-color: rgb(238, 235, 235);
6+
font-family: Arial, sans-serif;
7+
margin: 0;
8+
padding: 20px;
9+
}
10+
11+
h1 {
12+
text-align: center;
13+
font-size: 2.5rem;
14+
color: ;
15+
}
16+
17+
p {
18+
font-size: 1rem;
19+
color: ;
20+
}
21+
22+
button {
23+
background-color: rgb(221, 235, 116);
24+
color: rgb(131, 95, 29);
25+
border: none;
26+
padding: 10px;
27+
border-radius: 5px;
28+
}

0 commit comments

Comments
 (0)