I wrote an if condition where the return value is the indexOf an array. The if condition is failing when the first object of the array is returned (index of which is 0). Is there any way to fix this?
I'm checking if the value term is present in the array.
My code is:
if (array.indexOf(term)) {
//do something
}
else {
alert("error");
}