Skip to content

WESTMIDLANDS-JAN-ITP|SEGUN FOLAYAN|DATA GROUPS|SPRINT3-QUOTE GENERATOR #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
8 changes: 6 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@

<!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</title>
<script defer src="quotes.js"></script>
</head>
<body>
<div id = "container">
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
</html>
13 changes: 13 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,16 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const Quote = document.getElementById("quote");
const Author = document.getElementById("author");
const NewQuote = document.getElementById("new-quote");
Comment on lines +494 to +496
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal convention is to start a variable name with a lowercase letter. Names that begin with an uppercase letter are typically given to User-defined Type/Class in JS.

To make variable names (for storing DOM objects) more meaningful, a better practice is to add a suffix to the variable names. For examples, quoteEl, authorEl, newQuoteButton.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you



function display(){
const indexQuotes = pickFromArray(quotes)
Quote.textContent = `${indexQuotes.quote}`;
Author.textContent = `${indexQuotes.author}`;
}

window.onload = display;
NewQuote.addEventListener("click", display)
19 changes: 19 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
/** Write your CSS in here **/
body {
background-color: #90EE90;
padding-top: 75px;
}
#container {
background-color: white;
border: 5px solid;
height: 500px;
width: 750px;
margin: 0 auto;
text-align: center;
}
#new-quote {
margin: 50px auto;
height: 50px;
width: 250px;
font-size: 22px;
background-color: #90EE90;
}