
Design comparison
Solution retrospective
It took me 14 hours, 10 minutes, and 20 seconds to finish this. I'm pretty sure that the code is not the best I've written or that you guys have ever seen, but it was the very first JavaScript code I ever wrote. I had no idea about it, but after finishing this, I understood and learned a lot. Any feedback is extremely appreciated.
What challenges did you encounter, and how did you overcome them?The biggest challenge, besides learning JavaScript from scratch, was the share logo effect on mobile. It was really confusing to implement, but in the end, I managed to overcome it.
What specific areas of your project would you like help with?All the JavaScript code.
Community feedback
- P@yudin7324Posted about 2 months ago
What’s Good:
- Clear structure and well-defined event handling.
- Uses classList.contains to check active states.
- Applies styles dynamically based on state changes.
Areas for Improvement:
1.Avoid Code Duplication:
- Instead of if-else, you can use classList.toggle(className, condition) to simplify state management, though it’s not always necessary.
- This reduces redundancy when modifying the same elements in both conditions.
2.Optimize Style Updates:
- Instead of manually changing backgroundColor and filter, you could use CSS classes to handle styling.
- This keeps JavaScript logic cleaner and separates concerns.
3.Avoid setTimeout for Class Removal:
- Consider using CSS animations instead of setTimeout, as it improves maintainability and ensures smooth transitions.
4.Avoid Using var:
- It’s recommended to avoid using var as it has function scope and can lead to unexpected behavior due to its hoisting nature.
- Use let or const instead, which have block scope and are generally safer and more predictable.
- const is preferred when the variable won’t be reassigned.
- let is suitable when you need to reassign the variable.
Your code is well-structured, but reducing duplication and relying more on CSS for styling and animations will improve maintainability and performance
Good luck in the next challenge!
Marked as helpful0
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