Im trying to check an array for a value as such. not sure how to go about. If anyone could help that would be great.
var array1 = [0];
if (DONT KNOW WHAT TO SAY TO CHECK FOR 0 IN THE ARRAY) {
Do something
}
Im trying to check an array for a value as such. not sure how to go about. If anyone could help that would be great.
var array1 = [0];
if (DONT KNOW WHAT TO SAY TO CHECK FOR 0 IN THE ARRAY) {
Do something
}
DONT KNOW WHAT TO SAY TO CHECK FOR 0 IN THE ARRAY
If you want to check for 0 in the array1 (anywhere in the array), then use indexOf
if (array1.indexOf(0) != -1)
{
Do something
}
contains method developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…contains may mean that you are looking for value which has 0 as substring.You need to access the array. If you have no idea what place the array is you need to go through the array.
for (var i = 0; i < array.length; i++) {
if (array[i] == 0) {
//Do all the things
}
}