For me the book "clean code" was an eye opener. It's a bit extreme, but the fundamentals are awesome. The most important point is to have small functions with good names. This helps you to structure your code and improves readability.
For example I would move the add/remove class line to it's own function. Personally I also don't like the chaning, because it's terrible to read. Also move all const to the outside of your function. Document ready inside a function is also pretty unusual.
Your code, espacially the template part, could be improved by using string literals.
Happy coding and I hope we will see an refactored version.
The add/remove class recommendation makes total sense, I just hadn't thought of it that way. The chaning is something I want to try and avoid and make the code more generic. Good point on the document ready, I'll have to make an adjustment.
Excellent point on string literals, I could definitely utilize that to improve the readability.
Appreciate the insight!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For me the book "clean code" was an eye opener. It's a bit extreme, but the fundamentals are awesome. The most important point is to have small functions with good names. This helps you to structure your code and improves readability.
For example I would move the add/remove class line to it's own function. Personally I also don't like the chaning, because it's terrible to read. Also move all const to the outside of your function. Document ready inside a function is also pretty unusual.
Your code, espacially the template part, could be improved by using string literals.
Happy coding and I hope we will see an refactored version.
This is exactly what I was hoping to hear.
The add/remove class recommendation makes total sense, I just hadn't thought of it that way. The chaning is something I want to try and avoid and make the code more generic. Good point on the document ready, I'll have to make an adjustment.
Excellent point on string literals, I could definitely utilize that to improve the readability.
Appreciate the insight!