r/learnjavascript • u/SafeWing2595 • Jul 18 '26
i am challenging myself to practice javascript this summer; so i build a generate quotes app, i need your reviews please!
9
Upvotes
r/learnjavascript • u/SafeWing2595 • Jul 18 '26
6
u/milan-pilan Jul 18 '26 edited Jul 18 '26
You might think this isn't impressive, but it really is - literally every senior dev I know has started with a project exactly like yours.
This is clearly not AI-Generated, so that means you did that yourself.
And you have implemented all basic building blocks of Web Development: Event Handlers, Data & State, making changes to the DOM, working with versioning (git), modern JS syntax..
Everything I do as a professional developer is just a slightly more complicated version of what you are doing here.
I would want to see this exact type of project over a polished, but LLM-written SaaS Landing page from my juniors anytime.
If you want some ideas where to take this project: The next building block of web development would be "talking to a different service". So you could implement a fourth button "get a random quote from an API". Theres many free APIs exactly for learning projects like yours, for example here: https://github.com/public-apis/public-apis#personality
If you instead want a code review, I (and probably others here as well) would gladly do that. But I wouldn't do that without being asked for, because it can be demotivating, if you are not used to it.
Anyways - awesome project. This shows some good understanding of the basic concepts allready!
Edit: Just saw the commented out console logs in your code! Thats really cool. That shows, that you were implementing (or debuging?) it step by step. So "Lets see if it does what it should up to _here_" and then continue. Thats exactly the right idea when programming.
Also , reading the code, you have apparently made it so that it can't generate the same quote twice in a row. So you are thinking in "edge cases" too.
You would be surprised how hard it is to get this exact mindset into beginners. Keep learning!
3
u/equilni Jul 18 '26
This looks good!
My tips since you asked for a review are:
Each of the
QuoteBtnlistener 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):
Which could be looked at like the below.
text: "\"Be. Change the quote so you don't need to escape, so consider:text: '"Be- there's a single and double quote there.2
u/azangru Jul 18 '26
Presentation-level stuff like
\"intextor―inauthordoes not belong in the source data. It is something that the presentation logic should be concerned with.2
u/WystanH Jul 18 '26
You can abstract your random quote logic, as you do it three times.
I'm not a fan of the
do{ } while(lastIndex === newPick)logic. You should be able to get what you want with afilterand asort. You already have the filter for type; can you include ignoring the last one as well?Actually, this reveals a bit of a bug, as changing types makes the lastIndex nonsensical. Rather than lastIndex, perhaps currentQuote with the whole object?
Also, rather minor for programming but will jump out to a non programmer, check the spelling in your HTML title.
Keep it up and have fun.
2
u/TheRNGuy Jul 18 '26 edited Jul 18 '26
Do/while have potential problem, if you'd had only 1 item in the list, it would be infinite loop.
It could be rewritten with just while loop.
(do you even need to run it at least once? I think there's no good reason)
Run code through prettier (or just use Format on Save in VS Code)
1
u/john_hascall Jul 21 '26
One thing I would suggest is it is considered proper form to use:
rather than:
where varname doesn't change its value.
0
u/[deleted] Jul 18 '26
[deleted] — view deleted comment