Recently I was tasked with creating a Flash Chart Application for Pollster.com. One of the challenges in building this app involved allowing the user to turn on and off specific types of poll data, ie. live phone, automated, internet or mail based polls. Sounds simple enough, right? It was. The challenge camewith giving the user the ability to filter out specific pollsters within each category or “mode”. The reason this was a challenge was due to the fact that each category had a pollster associated with multiple data points within the chart, therefore, the list consisted of many repeat listings of the same pollster name.
Being that I already had an array created from the data feed, which was used to place the data points, I figured I could pull my list of pollsters from that array to create my new “pollster” array. Now, there are a ton of ways to accomplish such a task, but I want to focus on one specific method that I used. The every() method of the Array class. I’ve read a lot about people using splice(), slice(), pop(), shift(), etc., but nothing about every(). Nothing at all. Ever . So I figured I’d use it to accomplish the task at hand.
Basically, every() “executes a test function on each item in the array until an item is reached that returns false for the specified function” – Adobe LiveDocs. So let’s get on with some sample code… (more…)
