Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
16 changes: 13 additions & 3 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</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>
<div class="card">
<div class="quote-container">

<span class="quote-mark">“</span><p id="quote"></p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems to have open quote-marks but can't see any closing

@Motorcycle-lab Motorcycle-lab Jul 30, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have added now

<p id="author"></p> </div>

<div class="button-container">

<button type="button" id="new-quote">New quote</button>
</div>
</body>

</html>


31 changes: 27 additions & 4 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
// DO NOT EDIT BELOW HERE

//
// pickFromArray is a function which will return one item, at
// random, from the given array.
//

// Parameters
// ----------
// choices: an array of items to pick from.
//

// Returns
// -------
// One item at random from the given array.
//

// Examples of use
// ---------------
// 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)];

function pickFromArray(quotes) {
return quotes[Math.floor(Math.random() * quotes.length)];
}
// First condition: When a person click the button, it should generate back a quote;

function updateWebpageWithQuote() {
const elem = document.querySelector("#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.

Can you think of better names for your variables, which describe the intent?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

quoteDisplay and authorDisplay

const elem2 = document.querySelector("#author");

// store into the variable
const elem3 = pickFromArray(quotes);
elem.innerText = elem3.quote;
elem2.innerText = elem3.author;
}

// Second condition: when a person enter the website, it should have a quote appear;

// Third condition: when a person clicks the button each time, it should have different quote. .

// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
Expand Down Expand Up @@ -490,4 +508,9 @@ const quotes = [
},
];

const buttonElem = document.querySelector("#new-quote");

buttonElem.addEventListener("click", updateWebpageWithQuote);
updateWebpageWithQuote();

// call pickFromArray with the quotes array to check you get a random quote
60 changes: 60 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
/** Write your CSS in here **/
/** Write your CSS in here **/

body{

background-color:orange;
margin:0;
display: flex;
min-height: 100vh;
justify-content: center;
align-items:center;
}


.card{
background-color: white;
padding:30px;
border-radius: 8px;
max-width: 500px;

}

.quote-container{
display: flex;
align-items: flex-start;
gap: 15px;
}

.quote-mark{
font-size: 90px;
color: orange;
line-height: 1;
font-family: sans-serif;

}


#quote{
color: orange;
font-size: 24px;
}

#author{
color: orange;
font-size: 24px;
}

.button-container{
display:flex;
justify-content:flex-end;
min-height: 50px;

}

#new-quote{
background-color: orange;
color:white;
border: none;
}


Loading