You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe in the function_returns_object.html the various randomly generated array indices in the makeCar() function use bad coding practices in the naming of the variables. The variables are named "rand1, "rand2", and so on. They are ambiguous because refer to an index of a specific array, not just any random number.
This does not cause a problem in the code at the moment as all of the arrays are the same length, but it could cause problems later if some of the arrays had different lengths. Because of the ambiguity it would be an easy mistake to use rand3 as the randomly selected color index and with arrays of differing lengths it would eventually cause undefined objects. It also takes unnecessary time to check which array each "rand" variable refers to.
Of course this is just a small and simple programming exercise but I believe it is still good to promote proper coding practices, especially in pre-written example code.
The text was updated successfully, but these errors were encountered:
I believe in the function_returns_object.html the various randomly generated array indices in the makeCar() function use bad coding practices in the naming of the variables. The variables are named "rand1, "rand2", and so on. They are ambiguous because refer to an index of a specific array, not just any random number.
This does not cause a problem in the code at the moment as all of the arrays are the same length, but it could cause problems later if some of the arrays had different lengths. Because of the ambiguity it would be an easy mistake to use rand3 as the randomly selected color index and with arrays of differing lengths it would eventually cause undefined objects. It also takes unnecessary time to check which array each "rand" variable refers to.
Of course this is just a small and simple programming exercise but I believe it is still good to promote proper coding practices, especially in pre-written example code.
The text was updated successfully, but these errors were encountered: