ga-wdi-exercises / pixart_js

Use JS events and programmatically generated DOM elements to build a drawing application. [javascript, dom]
MIT License
9 stars 321 forks source link

maureen solution #161

Closed maureenv closed 8 years ago

maureenv commented 8 years ago

I had trouble pushing my git branch, so I had to push it without branching. After attempting to make this game many times I decided to study the solution and finally understood how it's done. However, I don't understand why "this" needs to be used on line 28 (typing in my variable "square" instead of "this" prevents the game from working). I figured that maybe it only works when I type "this" because the variable "square" is inside of an anonymous function.

I also attempted to do the bonus question but had too much getting the brushes to change color according to the input.

RobertAKARobin commented 8 years ago

Inside event listener functions, this always refers to the element that was clicked on. If you already have that element saved to a variable, you can use that variable instead: either is fine.