i need to determine if a value exists in an array using javascript.
I am using the following function:
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if (this[i] == obj) {
return true;
}
}
return false;
}
The above function always returns false.
The array values and the function call is as below
arrValues = ["Sam","Great", "Sample", "High"]
alert(arrValues.contains("Sam"));
Please suggest what to do