Skip to content

WESTMIDLANDS | ITP-MAY-2025| SARA TAHIR| Sprint 3 | Quote generatar #621

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
11 changes: 7 additions & 4 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<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>
<h1>Hello there</h1>
<div class="quote-box">
<p id="quote">Quote goes here...</p>
<p id="author">Author goes here...</p>
</div>
<button type="button" id="new-quote">New quote</button>
</body>
</html>
31 changes: 28 additions & 3 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
// 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!
Expand Down Expand Up @@ -489,5 +495,24 @@ const quotes = [
author: "Zig Ziglar",
},
];
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
function displayRandomquote(){
const randomQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = randomQuote.quote;
document.getElementById("author").textContent = randomQuote.author;
}

displayRandomquote();


document.getElementById("new-quote").addEventListener("click", () => {
displayRandomquote();
});

// call pickFromArray with the quotes array to check you get a random quote
/*My First step to generate a quote
const randomQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = randomQuote.quote;
document.getElementById("author").textContent = randomQuote.author;*/
46 changes: 46 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
/** Write your CSS in here **/

body {
font-family: sans-serif;
text-align: center;
padding: 40px;
background-color: #f0f0f0;
}

h1 {
margin-bottom: 30px;
color: #34063c;
}

.quote-box {
background-color: rgb(139, 191, 193);
border-radius: 10px;
padding: 30px;
margin: 0 auto 20px;
max-width: 500px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#quote {
font-size: 1.5rem;
font-style: italic;
margin-bottom: 20px;
}

#author {
font-weight: bold;
color: #260559;
}

#new-quote {
padding: 10px 20px;
font-size: 1rem;
background-color: #00cc66;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

#new-quote:hover {
background-color: #005fa3;
}