Design comparison
Solution retrospective
Is there any way to improve my code?
Community feedback
- @efedericomedinaPosted over 1 year ago
Hi, really nice work Anisha, the ui looks good and its nice to see how you used the correct html tags and the if statement within the functions.
I leave you some points to consider: In the html file, the img tags don't have the alt attribute set, maybe adding a text to those would be nice and cover a part of accessibility.
In the css file, what do you think about using variables to store the colors? and then use those variables whenever you need to indicate a color instead, if the color happen to change in the future then you only need to update the variable value in one place instead of having to update the color everywhere. check(https://www.w3schools.com/css/css3_variables.asp)
In the js file the function focusState, maybe could be simplified, I see that the first function's argument is the one that changes color only, maybe instead of passing all the params, only passing that id that changes colors on focused event and the rest of the ids, you could use a for-loop to change the colors since they are all the same.
afterHoverSubmit and hoverState are the same functions though the names changes, maybe having one function with a more generic name will allow you to reuse your function.
Maybe instead of assigning the hardcoded colors on the functions, you could use constants to declare the colors outside the functions and the use them whenever needed.
Marked as helpful1
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