some method to check an array in JavaScript
The following method some checks the
array elements and returns true if
the callback returned true for at
least one element, otherwise the method
returns false.
Let's check, for example, that there is at least one even number in the array:
javascriptlet arr = [2, 4, 6, 8];
let result = arr.some(function(elem) {
return elem % 2 == 0;
});
console.log(result);
Let's simplify:
javascriptlet arr = [2, 4, 6, 8];
let result = arr.some(elem => elem % 2 == 0);
console.log(result);
Задание 1
Given an array of numbers. Check that the array contains at least one number greater than zero.
Задание 2
Given an array of numbers. Check that
for at least one element the product
of its value and index number is
greater than 30.