I think that learning about code is not just doing exercises, building apps, or hitting the books. I believe that when you teach what you’ve learned, you learn what you teach.
Today is a day that taught what I learned. As I mentioned before, I am part of Grow with Google – Udacity Developer Challenge. There are 10k of us vying for 1500 scholarships to Udacity’s Front End Nanodegree.
Although we are all in competition, surprisingly, we all help each other.
Some of my cohort mates needed some help with working on their final projects. It requires jQuery to listen to events on the page.
The main issue was that they wanted to implement a click and drag function so that they can change background colors on cells on a table by dragging the mouse.
I struggled with this a little bit but I learned it. So, now I’m teaching it.
To do this, you need to listen to both click and mouseover. Then, pass the event parameter to your function. That event has a property called buttons. We will use that in a conditional to check if it is currently clicked or not. The value of a clicked button is 1. So, if event.buttons is 1, we paint the cell. If not, we do nothing.
So, that’s it for today. See you tomorrow.