Using global variables is a smell and common source of bugs, especially in a language like javascript. I'd recommend to read the book Clean Code. It has code examples in Java but the principles are language agnostic.
I see what he's getting at.
I don't like how he explained it.
The idea that the doggos variable shouldn't be duplicated is pretty self-evident, as it's both constant and effectively an additional helper function.
doggos
I doubt it belongs in the global scope, but it's reasonable to put it into the same scope as the functions that use it.
You are right it is a constant, I just wanted to highlight the duplication part from a beginners perspective
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Using global variables is a smell and common source of bugs, especially in a language like javascript. I'd recommend to read the book Clean Code. It has code examples in Java but the principles are language agnostic.
I see what he's getting at.
I don't like how he explained it.
The idea that the
doggos
variable shouldn't be duplicated is pretty self-evident, as it's both constant and effectively an additional helper function.I doubt it belongs in the global scope, but it's reasonable to put it into the same scope as the functions that use it.
You are right it is a constant, I just wanted to highlight the duplication part from a beginners perspective