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
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<!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 app</title>
<script defer src="quotes.js"></script>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

JavaScript File linked correctly to html.

</head>
<body>
Expand Down
21 changes: 21 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,24 @@ const quotes = [
];

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

// getting the input and button elements from the page
const quoteElement = document.getElementById("quote");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

document.getElementById() is one of the way of accessing DOM elements. You can explore more DOM methods.

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

function displayRandomQuote() {
// get a random quote from the quotes array
const randomQuote = pickFromArray(quotes);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

pickFromArray(quotes) used correctly.


// update the quote and author elements
quoteElement.textContent = randomQuote.quote;
authorElement.textContent = randomQuote.author;
}

displayRandomQuote(); // display a random quote when the page loads

// display a new random quote when button is clicked
buttonElement.addEventListener("click", () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Event handler used correctly.

displayRandomQuote();
});
41 changes: 41 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
/** Write your CSS in here **/

body {
font-family: Arial, sans-serif;
background-color: #d8b4db;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}

h1 {
color: #934a87;
}
#quote {
font-size: 1.5em;
background-color: #d12fe0;
color: #f6f9f5;
margin: 20px;
text-align: center;
max-width: 600px;
padding: 20px;
border-radius: 10px;
}

#author {
font-size: 1.2em;
color: #934a87;
margin-bottom: 20px;
}

button {
padding: 10px 20px;
font-size: 1em;
background-color: #d12fe0;
color: #f6f9f5;
border: none;
cursor: pointer;
border-radius: 50px;
}
Loading