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
4 changes: 3 additions & 1 deletion Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<link rel="stylesheet" href="style.css">
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<p class="container">Test</p>
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.

What's the purpose of this element (line 14)?

<button type="button" id="new-quote">New quote</button>
</body>
</html>
17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,20 @@ const quotes = [
];

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

console.log(pickFromArray(quotes));
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.

Any unnecessary code should be removed to keep our code clean.


const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");
const button = document.getElementById("new-quote");

function showQuote() {
const randomQuote = pickFromArray(quotes);

quoteElement.textContent = randomQuote.quote;
authorElement.textContent =randomQuote.author;
}

button.addEventListener("click", showQuote);

showQuote();
Comment on lines +508 to +510
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.

Placing all the "run on load" code in one place is a good practice.
Would be even better to place the code inside a function to make it clearer that "this is what runs when the page loads."

For examples,

function setup() {
  // code to be executed on page load
}

window.addEventListener('load', setup);

or

window.addEventListener('load', function() {
  // code to be executed on page load
});

33 changes: 33 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
background-color: purple;
text-align: center;
padding: 50px;
}

.container {
background: blue;
padding: 20px;
border-radius: 10px;
display: inline-block;
}

#quote {
font-size: 1.5em;
margin-bottom: 10px;
}

#author {
font-style: italic;
margin-bottom: 20px;
}

button {
padding: 10px 20px;
font-size: 1em;
cursor: pointer;
}

.autoplay {
margin-top: 20px;
}
Loading