Actionscript 3: Check an array for a match
actionscript-3, arrays, match
Solution
`Array` class has an `indexOf` method:
`function indexOf(searchElement:*, fromIndex:int = 0):int`
Searches for an item in an array by using strict equality (===) and returns the index position of the item.
Parameters
- `searchElement:*` — The item to find in the array.
- `fromIndex:int` (default = 0) — The location in the array from which to start searching for the item.
Returns
- int — A zero-based index position of the item in the array. If the `searchElement` argument is not found, the return value is -1.
Problem
If you have an array with six numbers, say: ``` public var check:Array = new Array[10,12,5,11,9,4]; ``` or ``` public var check:Array = new Array[10,10,5,11,9,4]; ``` How do you check for a match (of a pair?)