You mean *ANYWHERE* in the array???
In other words, if you search for the value 3
and it is in *ANY* element of the array then you want to return true? else false?
You don't even need a function: [code]
var myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var findit = ( myArray.indexOf(3) >= 0 ); // will put true into findit
var findit = ( myArray.indexOf(731) >= 0 ); // will put false into findit
Except older MSIE browsers don't have the indexOf method on arrays.
But that's easy to fix:
if ( Array.prototype.indexOf == null )
function( lookFor )
for ( var i = 0; i < this.length; ++i )
if ( this[i] == lookFor ) return i;
Now Array.indexOf( ) will be there whatever browser you use.