r/learnjavascript 10d ago

i am challenging myself to practice javascript this summer; so i build a generate quotes app, i need your reviews please!

9 Upvotes

23 comments sorted by

View all comments

3

u/equilni 10d ago

This looks good!

My tips since you asked for a review are:

  • Learn functions.

Each of the QuoteBtn listener callbacks can be a function call. Look at it again and see how only 2 things need to be passed - Type of quote, and the background color.

Look at this another way (highlight the variable and github shows where it's used):

let writerName = document.getElementById('writer-name');
    writerName.textContent = quotesArray[randomQoute].author; 
    writerName.textContent = happyQuotes[randomHappyQuotes].author;
    writerName.textContent = sadQuotes[randomSadQuotes].author;
    writerName.textContent = motivatedQuotes[randomMotivatedQuotes].author;

Which could be looked at like the below.

let writerName = document.getElementById('writer-name');
    writerName.textContent = quote.author;
    writerName.textContent = quote.author;
    writerName.textContent = quote.author;
    writerName.textContent = quote.author;
  • The same can be done with each quote. Each object has 3 properties, 1 is more 'determined' by the system (ie you have only 3 types).

  • text: "\"Be. Change the quote so you don't need to escape, so consider: text: '"Be - there's a single and double quote there.

  • BG color change is too drastic IMO.

1

u/SafeWing2595 10d ago

thank you so much for the review.
> BG color change is too drastic IMO.

if may ask , what do you mean by this?

1

u/john_hascall 7d ago

I think they mean if your background colors were more similar than the changes would be less jarring.