// .every accepts a function as an argument, but returns true
// only if the function matches for every item.
const numbers = [5, 55, 66, 33, 23, 12, 98, 44];
const greaterThanTen = (element) => element > 10;
console.log(numbers.every(greaterThanTen));
//Expected output is false
<script>
// JavaScript code for every() function
function isodd(element, index, array) {
return (element % 2 == 1);
}
function geeks() {
var arr = [ 6, 1, 8, 32, 35 ];
// check for odd number
var value = arr.every(isodd);
console.log(value);
}
geeks();
</script>
var nums = [1, 2, 3, 4, 5, 6, 7];
function even(ele)
{
return ele%2 == 0;
}
console.log(nums.every(even))
/*console.log will show false since not every element is even*/
<script>
// JavaScript code for every() method
function isodd(element, index, array) {
return element % 2 == 1;
}
function func() {
var arr = [56, 91, 18, 88, 12];
// Check for odd number
var value = arr.every(isodd);
document.write(value);
}
func();
</script>
let array_4 = [50,71,20,29,31,19];
function CheckAdult(value){
return value >= 18;
}
let array_5 = array_4.every(CheckAdult);
console.log(array_5);
// OUTPUT: true
console.log(typeof(array_5));
// OUTPUT: boolean
// When we check the type of of that variable in which we use every(),
// so it will return us boolean data type,
// because every() returns us true or false after checking if all value of array is satisfied with the condition.