Testing Every Element
You want to be able to check that every element in an array meets a particular condition.
Use Array.every (ECMAScript 5):
_.all from underscore.js.
For a real world example, pretend you have a multiple select list that looks like:
Now you want to verify that the user selected only numbers. Let's use Array.every:
This is similar to using ruby's Array#all? method.