Responsive landing | nested grids and flex | Media queries
Design comparison
Solution retrospective
I really enjoyed this project. The nested grids and flexbox layouts were very pleasant to make. I have questions about my JS file: an ideas on how upgrade it?
Community feedback
- @rafaeldevvvPosted over 1 year ago
Hey there! Congratulations on completing the challenge!
The JS code is good but there are always room for improvement.
The first thing to note is the use of variables. Consider using "const" to declare a variable instead of "var" or "let" when it is not meant to be reassigned. It can improve code readability and maintanibility. Also, prefer using "let" and "const" over using "var". Declaring variables with "var" can cause some scope bugs. Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Declarations
Secondly, you declared variables that hold the same value in different functions. It is better to declare all variables outside both functions and use them inside the functions. This reduces redundancy making the code more readable.
Thirdly, you are managing each list item when you open or close the menus. I think it would be a better solution to manage the list itself when it is needed to show or hide the items.
Last, you could use that shortcut, the $ notation, to select DOM nodes to make the code shorter.
Those are my suggestions for you. Again, congratulations on completing the challenge! Hope I helped! 👍😁
Marked as helpful0@PedrodeCTedescoPosted over 1 year ago@rafaeldevvv E ai! cara, valeu mesmo. Vou começar a seguir essas orientações para deixar o arquivo de JavaScript mais organizado e fácil de ler.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord