1 var fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"];
2
3 // Check if a value exists in the fruits array
4 if(fruits.indexOf("Mango") !== -1){
5 alert("Value exists!")
6 } else{
7 alert("Value does not exists!")
8 }
1const fruits = ['apple', 'banana', 'mango', 'guava'];
2
3function checkAvailability(arr, val) {
4 return arr.some(arrVal => val === arrVal);
5}
6
7checkAvailability(fruits, 'kela'); // false
8checkAvailability(fruits, 'banana'); // true
1private boolean ZitAlInArray(int value, List<Integer> list) {
2 return array.indexOf(value) > -1;
3}
4
5private boolean zitAlInArray(int[] array, int index) {
6 for (int i = 0; i < index; i++) {
7 if (array[i] == array[index]) {
8 return true;
9 }
10 }
11 return false;
12 }
13