Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Sprint-3/quote-generator/index.html
Comment thread
cjyuan marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<link rel="stylesheet" href="style.css" />
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div class="displayArea">
<p id="quote">hello there</p>
<p id="author">Quote by</p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
36 changes: 15 additions & 21 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
// random, from the given array.
//
// Parameters
// ----------
// choices: an array of items to pick from.
//
// Returns
// -------
// One item at random from the given array.
//
// Examples of use
// ---------------
// 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)];
}

// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
const quotes = [
{
quote: "Life isn't about getting and having, it's about giving and being.",
Expand Down Expand Up @@ -490,4 +470,18 @@ const quotes = [
},
];

// call pickFromArray with the quotes array to check you get a random quote
const areaOfQuote = document.querySelector("#quote");
const shufflebutton = document.querySelector("#new-quote");
const AreaOfQuoteBy = document.querySelector("#author");

function quoteGenerator() {
const entireQuote = pickFromArray(quotes);
const quot = entireQuote.quote;
const Author = entireQuote.author;
areaOfQuote.textContent = quot;
AreaOfQuoteBy.textContent = Author;
}

quoteGenerator();

shufflebutton.addEventListener("click", quoteGenerator);
48 changes: 48 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
/** Write your CSS in here **/
.displayArea {
position: fixed;
border-style: groove;
border-top-left-radius: 0%;
top: 50%;
left: 50%;
width: 75%;
transform: translate(-50%, -50%);
background-color: whitesmoke;
}
body {
background-color: rgb(223, 208, 182);
}
#new-quote {
border-style: outset;
font-size: larger;
color: whitesmoke;
margin-left: 80%;
margin-bottom: 10px;
background-color: rgb(226, 203, 163);
block-size: 50px;
}
#new-quote:hover {
color: black;
border-right-width: 10px;
border-bottom-width: 10px;
}

#quote {
display: block;
font-size: 2em;
margin-block-start: 0.67em;
margin-block-end: 0.67em;
font-weight: bold;
text-align: center;
margin-right: 20px;
color: rgb(226, 203, 163);
}
#author {
font-size: 1.17em;
font-weight: bold;
margin-block-start: 1em;
margin-block-end: 1em;
display: block;
text-align: right;
margin-right: 20px;
color: rgb(226, 203, 163);
}
Loading