A few days ago I developed a hangman game with vanilla JS. There’s only so much you can do whilst reviewing your own code, so I’d be very grateful if you could take 5 minutes to review the code and provide some useful feedback on where it can be improved.
I didn’t spend any time on the actual design of the project, so you’ll have to excuse how it looks, as my focus was on the functionality offered (I’ll probably get back to the design at a later date).
Any chance you can put it up on CodePen or CodeSandbox? That’ll make it easy for people to play around with your game and give feedback on the code while it’s running (in contract, to static code review).
I’m not a good code reviewer, but I’ll have a look at your repo and see if there’s anything that can be improved.
Thanks for your feedback, I find it really useful!
The inconsistency with the arrow functions is purely an oversight of mine - I need to go back and review to make it consistent!
The validation of the game settings (difficulty) also needs to be implemented, this is something i’d forgotten to include in my test cases. Whilst the game is playable if both fields are unanswered (it uses a default setting), it’s seems to be poorly designed if leaving them blank has no impact.
Thanks so much for the other feedback, I always find it difficult to go back and review my work (especially so soon after creating it as i’ll still be in the same mindset). I really appreciate your time on this.
And if you review your code again, try making it more DRY (Don’t Repeat Yourself) along the way.
Duplicate codes are difficult to manage; it’s okay for small projects but as the project gets bigger and bigger, the mess will accumulate thus making it difficult to maintain.
Making a habit out of DRYing up code is difficult but with practice, I’m confident that you’ll get good at it.
That’s okay. I just recently learned about the difference between the two myself.
I’m not sure in which book, but You Don’t Know JS elaborated a lot about this.
Haha we’re the same. It’s very good that you seek feedback though because it’s difficult to see the flaws in our own codes.
I played around the game. First thing I noticed is that the game doesn’t reset when a victory or defeat condition is reached. It just stuck there with the message you win or you lose.
Other that, the code is quite clean. Not much problem understanding what you did. I did cheat while guessing. LOL