js some vs any code example
Example 1: js find array return true false
['one', 'two'].some(item => item === 'one')
['one', 'two'].some(item => item === 'three')
Example 2: javascript some
const age= [2,7,12,17,21];
age.some(function(person){
return person > 18;});
const age= [2,7,12,17,21];
age.some((person)=> person>18);
Example 3: javascript some
const fruits = ['apple', 'banana', 'mango', 'guava'];
function checkAvailability(arr, val) {
return arr.some(function(arrVal) {
return val === arrVal;
});
}
checkAvailability(fruits, 'kela');
checkAvailability(fruits, 'banana');