Repository navigation
Glasgow | 26-ITP-May | Chan Yat Long | Sprint 3 | Quote generator #1251
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
Motorcycle-lab
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
Motorcycle-lab:new-quote-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! | ||
|
|
@@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added now