This functions returns ‘true’ and the element, if the passed value is in the to-be-checked array and like-wise.
CheckValueInArray = function(arr,val){
var inArray = false;
var whereIn = 'notIn';
for(a=0; a<arr.length; a++)
if (val == arr[a]){
inArray = true;
whereIn = a;
}
return {inArray:inArray,whereIn:whereIn}; //returning multiple values
}
Advertisements