Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 3| Quote generator#1165
Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 3| Quote generator#1165Darkidd77 wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
jayshreehajgude2012
left a comment
There was a problem hiding this comment.
Good use of inbuild functions.
Work on cleanliness of the code.
Explore more DOM methos to access elemnts.
| <title>Title here</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <title>Quote generator app</title> | ||
| <script defer src="quotes.js"></script> |
There was a problem hiding this comment.
JavaScript File linked correctly to html.
|
|
||
| // You don't need to change this function | ||
| function pickFromArray(choices) { | ||
| return choices[Math.floor(Math.random() * choices.length)]; |
There was a problem hiding this comment.
inbuilt functions correctly used.
| // 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"); |
There was a problem hiding this comment.
document.getElementById() is one of the way of accessing DOM elements. You can explore more DOM methods.
There was a problem hiding this comment.
Thanks, I did some reading on modern DOM methods and discovered document.querySelector(). Which is more flexible and can target different element.
|
|
||
| function displayRandomQuote() { | ||
| // get a random quote from the quotes array | ||
| const randomQuote = pickFromArray(quotes); |
There was a problem hiding this comment.
pickFromArray(quotes) used correctly.
| displayRandomQuote(); // display a random quote when the page loads | ||
|
|
||
| // display a new random quote when button is clicked | ||
| buttonElement.addEventListener("click", () => { |
There was a problem hiding this comment.
Event handler used correctly.
| quote: | ||
| "It's your place in the world; it's your life. Go on and do all you can with it, and make it the life you want to live.", | ||
| author: "Mae Jemison", | ||
| }, | ||
| { | ||
| quote: | ||
| "You may be disappointed if you fail, but you are doomed if you don't try.", | ||
| author: "Beverly Sills", | ||
| }, | ||
| { |
There was a problem hiding this comment.
You can work on cleanliness of code.
There was a problem hiding this comment.
I am not really sure do you mean by cleanliness, is it to separate the quotes inna different file and export them and import them to the unction fie ?
Thank you
Learners, PR Template
Self checklist
Changelist