Skip to content

WESTMIDLANDS | ITP-MAY-2025| Roja Alagurajan| Sprint 3 | Quote generatar #694

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 3 commits 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
17 changes: 9 additions & 8 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>

<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>
Copy link

Choose a reason for hiding this comment

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

Can you explain what defer dees in script tag?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @day-lee ,
The defer attribute tells the browser to load the script while still parsing the HTML, but it waits to run the script until the HTML is fully loaded. This makes sure the JavaScript can safely access all elements on the page, like buttons or divs, without causing errors.

</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<div id="quote-container">
<p id="quote">"This is a placeholder quote."</p>
<p id="author">- Placeholder Author</p>
</div>
<button type="button" id="new-quote">New quote</button>
</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
@@ -1,3 +1,16 @@
function displayRandomQuote() {
const randomQuote = pickFromArray(quotes);
const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");

quoteElement.textContent = `"${randomQuote.quote}"`;
authorElement.textContent = `- ${randomQuote.author}`;
}

document.getElementById("new-quote").addEventListener("click", displayRandomQuote);

window.onload = displayRandomQuote;

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
51 changes: 51 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
background-color: #9cdcdc;
color: #333;
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 100vh;
}

#quote-container {
margin: 20px auto;
padding: 20px;
width: 80%;
max-width: 600px;
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: center;
}

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

#author {
font-size: 1.2em;
color: #555;
}

button {
margin: 20px auto;
padding: 10px 20px;
font-size: 1em;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}