Hi there!
I'm making my first steps in learning javascript.
Would you like to take a look at my practice project and provide some feedback? ๐
- I wonder what do you think about the functions and variable names.
- As well as the overall structure of the app.
It displays letters on the page and lets you practice typing.
Here is the link to the app https://type.ptifur.digital
And here is the source code
https://github.com/ptifur/javascript-practice
Top comments (6)
Congrats for getting the app out there!
I haven't checked the source code yet (will do that later) but a suggestion would be to automatically jump to the next "word" once you have finished the current one. I feel like the in-between-step of the site just saying "Well Done" and waiting for your input to start again is not needed.
Also, how about a mode/settings where you can choose to use real world words too? The source for the words could be a list of the 1000 most used words in the english language (I'm sure there are a ton of lists online available).
just leaving some thoughts/opinions in an unordered list:
use google analytics gdpr compliant
.<script>
of your JS file to the end of<body>
setTheUI.js
doesn't import anything or does anything fancy that it needs to be its own module. I'm sure you can find a different spot for it and get rid of the file entirely :).createBoxes
inutil.js
.createBoxes
is just a function in util butdisplayBoxes
gets its own .js file? It's not all bad but just heavily inconsistent.Example:
This file could also be named more generic, something like
userInput.js
.At some point in here you should probably check if the input,
letters
andnumber
are actually what they are supposed to be or if they even exist at all (aren't null/undefined). Something likecould be changed to
NEW_LETTERS
all in capslock probably because it's a global variable but the other globals aren't capitalized. Looking atscript.js
line 20 and 22.Since the page is doing what you want it to do it's definitely not bad :) Especially not when just starting out, you did good. From here it's just a constant process of iterating through optimisations and cleanup. I'd start by installing some formatter like Prettier to get the overall format in every file the same. Then go over and think about how you can A: rename files to make them more generic and B: merge some files because you really don't need to create a new file for just a singular function if this function isn't accessed by several other modules.
Hi! If there is room for one more question, here is where I'm stuck with this app ๐
I started working in a single file. Then made attempt to break it into modules. And when I move those
plus
andminus
event listeners to a separate file, I can't properly pass the NEW_LETTERS value back to the main app.Created new branch to illustrate it github.com/ptifur/javascript-pract...
Perhaps you could guide me in the right direction ๐ค
Easiest would be to write a function
setNewLetters
(choose whatever name) in your script.js that sets the value for you.So you can then call this function in your event listeners and update your variable this way. Skips passing values back and forth, back and forth.
Thanks for the insight!
Didn't know you can call the functions both ways. Guess this will save me some time stumbling through tutorials ๐
Thanks for an extensive review and encouragement!
That's superhelpful, I appreciate it!