Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 9 additions & 5 deletions Sprint-3/quote-generator/index.html
Comment thread
cjyuan marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
<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"> <h1>hello there</h1></p>
<p id="author">
<h3>Quote by</h3>
</p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,24 @@ const quotes = [
},
];

// getting access from the html
const showquote = document.querySelector("displayArea");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is this variable being used?

const areaOfQuote = document.querySelector("h1");
const shufflebutton = document.querySelector("#new-quote");
const AreaOfQuoteBy = document.querySelector("h3");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Better to use meaningful id or class names instead of relying on h1 and h3.

  • Is your text editor showing AreaOfQuoteBy and the other variable names in different colors. If so, do you know why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

my editor showing me with the same colors to the others

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you using VS Code? On GitHub, this is how they look like:

const shufflebutton = document.querySelector("#new-quote");
const AreaOfQuoteBy = document.querySelector("h3");

What I wanted to point out is that the naming convention for variables in JS is lower camel case.


// call pickFromArray with the quotes array to check you get a random quote

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The leading " and - appear to be for styling purposes. Keeping them in HTML or CSS could makes it easier to style or modify the view. This allows front-end developers to adjust the UI without changing any JavaScript code.

}
//console.log(quoteGenerator);
//console.log(quot);
//console.log(Author);
quoteGenerator();
//event handler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Best practice is to remove all unused code and unnecessary comments to keep the code clean.

shufflebutton.addEventListener("click", quoteGenerator);
38 changes: 38 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
/** 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;
}

h1 {
text-align: center;
margin-right: 20px;
color: rgb(226, 203, 163);
}
h3 {
text-align: right;
margin-right: 20px;
color: rgb(226, 203, 163);
}
Loading