Program to use JavaScript Array every() method
function evennumber(number) {
return number % 2 == 0;
}
let a = [3, 5, 7, 23, 13];
let b = a.every(evennumber);
console.log(b);
Output
false
Steps Description
- Declare function
evennumber
- Declare two variables
a
andb
- Initialize two variables
a
andb
with value of stringa = [3, 5, 7, 23, 13]
andb = a.every(evennumber)
Array every()
method checks array every element and returns boolean value- The value of
b
variable is displayed with the help of console.log inbuilt function