Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iteddy16
Copy link

…ndom quote functionality in JavaScript for Quote Generator App

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

  • It displays a quote randomly from the quote.js file and I apply some CSS features to make it look good.

Questions

Ask any questions you have for your reviewer.

…ndom quote functionality in JavaScript for Quote Generator App
@iteddy16 iteddy16 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Participant to add when requesting review labels Jul 22, 2025
@jenny-alexander jenny-alexander self-requested a review July 29, 2025 04:35
@jenny-alexander jenny-alexander added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 29, 2025
Copy link

@jenny-alexander jenny-alexander left a 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));

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() {

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/

Copy link
Author

Choose a reason for hiding this comment

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

Ok, thank you.

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;

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?

Copy link
Author

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.

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).

Copy link
Author

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 jenny-alexander added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 30, 2025
@iteddy16
Copy link
Author

@jenny-alexander, thank you for your comments and suggestions. I think I fixed the issue raised. Will you check it now? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants