-
-
Notifications
You must be signed in to change notification settings - Fork 155
LONDON | 25-ITP-MAY | TEWODROS BEKERE | M-D-G | SPRINT-3 | Quote_Generator_App #677
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
base: main
Are you sure you want to change the base?
Conversation
…ndom quote functionality in JavaScript for Quote Generator App
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.
Your quote generator works very well. I like your styling a lot too! Please review the comments and implement the suggested changes.
@@ -490,4 +510,5 @@ const quotes = [ | |||
}, | |||
]; | |||
|
|||
// call pickFromArray with the quotes array to check you get a random quote | |||
console.log(pickFromArray(quotes)); |
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.
It's a good idea to remove console logs before submitting your work for review.
@@ -1,3 +1,22 @@ | |||
function getRandomQuote() { |
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.
If your variable will not be reassigned within it's scope, it's better practice to use 'const' instead of 'let'.
Further reading: https://www.freecodecamp.org/news/differences-between-var-let-const-javascript/
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.
Ok, thank you.
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.
You did a great job assigning quote and author from the random quote object.
🌱 This suggestion isn't required but I wanted point out that you can use destructuring here. You can use object destructuring to extract both properties (quote and author) in one line. For example:
let { quote, author } = pickFromArray(quotes);
This is a common JS feature that lets you pull out several properties from an object at once
function pickFromArray(choices) { | ||
if (!Array.isArray(choices) || choices.length === 0) return null; |
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.
Since pickFromArray could possibly return null (i.e. if the quotes array was empty), what can you do to safeguard your code to ensure that if null is returned, your function doesn't throw an error?
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.
Fixed, it's handled by displaying an alert to the user.
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.
Can you run Lighthouse on your app? There are a few suggestions to implement in order to make your page a bit more accessibile.
(In order to run lighthouse, go to dev tools, and choose 'Lighthouse' from the menu of items available).
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.
No, I checked it was 93%. Now it's fixed the background color (white), and the new-quote button text (white) was the same; that's why.
@jenny-alexander, thank you for your comments and suggestions. I think I fixed the issue raised. Will you check it now? Thank you. |
…ndom quote functionality in JavaScript for Quote Generator App
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.