Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSteve Fan
8,218 PointsCode at line 62 in the video
The code line 61-63: }).mouseup(function(){ mouseDown = false; });
_I tried to use var "mouseDown" but It did not work at all, so just tried another way to do this. And when I moved to "Mouse Events" quiz. I just got a hint at the question: "Which of the following jQuery methods would I use to detect if someone presses down a mouse button and doesn't release it?" and the answer is "mousedown"
_So I made a try and It only work like the video when I modified "mouseDown" ==> "mousedown".
Anyone has same problems? How do you think about this prob? Is my understanding is in a right way?
I am quite confused when I do a different thing from the instructor and still get a result.
1 Answer
Steven Parker
231,275 PointsChanging variable names will still work as long as it is consistent.
If you change a variable name the same way throughout a program, you should always get the same result as before.
The problem occurs when you use a different variable name in one place from the name used elsewhere in the code. The name must always match, even though the name itself isn't important.
On the other hand, a method name must always be used the same way as it was defined. And both method and variable names in JavaScript are case-sensitive. So for example, the method to establish an event handler for pressing the mouse button is ".mousedown", all lower case. It won't work if spelled any other way.