Hello, please review my code and provide feedback. Seems to be working properly, but would appreciate any feedback if there is a better way of doing it!
Task: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Image_gallery
My code: https://github.com/djtanner/Learning/blob/master/gallery-start/main.js
Hi there @djtanner; welcome to our community, and thanks for sending your code in!
First of all, well done — the code works as expected, and I don’t really have any major criticism or suggestions for improvement.
The only thing I would comment on is variable declarations:
-
The xxx
variable is declared without a keyword like let
— this causes it to behave as if it were declared in the global scope, which doesn’t really matter in a simple example like this, but can cause unexpected behavior. I’d update that.
-
Later on in the code you use var
, but I’d think about making it more consistent — use let
instead, or even const
for everything that doesn’t have its value changed throughout the course of the program.
1 Like
Made those changes, thank you so much!