Skip to content
Closed
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
12 changes: 7 additions & 5 deletions 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>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div id="inner">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Copy link

@A-O-Emmanuel A-O-Emmanuel Nov 16, 2025

Choose a reason for hiding this comment

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

I noticed you've repeated these lines multiple times: const randomQuote =pickFromArray(quotes)
quoteDom.innerText = randomQuote.quote; authorDom.innerText = randomQuote.author; can you think of a way to remove this repetitions and keep your code DRY. You can read up on this on what I mean by DRY: DRY principle - GeeksforGeeks

Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
document.addEventListener("DOMContentLoaded", () => {
//elements of page to interact with
const quoteDom = document.getElementById("quote");
const authorDom = document.getElementById("author");
const button =document.getElementById("new-quote");
displayQuote(quoteDom, authorDom );

button.addEventListener("click",() => {
displayQuote(quoteDom, authorDom )
})
});

function displayQuote(quoteDom, authorDom ){
const randomQuote =pickFromArray(quotes);
quoteDom.innerText = randomQuote.quote;
authorDom.innerText = randomQuote.author;
}

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
23 changes: 23 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
/** Write your CSS in here **/
body{
background-color: orange;
}
#inner{
background-color: white;
width: 70%;
margin: 125px auto;
padding: 35px;
text-align: end;
}
p{
color: orange;

}
#quote{
font-size: 32px;
}
button{
background-color: orange;
color: white;
border: none;
padding: 10px;
}